我正在设置一个基本的RoR应用程序。我的所有数据库都是MySQL和本地,我的数据库,yml文件都包含在内。我试图访问基本视图但仍然收到ActiveRecord :: ConnectionNotEstablished错误。我做错了什么?
# database.yml
development:
adapter: mysql2
encoding: utf8
database: *****_dev
username: ****
password: *****
host: 127.0.0.1
port: 3306
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
database: *****_test
username: ****
password: *****
host: 127.0.0.1
port: 3306
production:
adapter: mysql2
encoding: utf8
database: *****_prod
username: ****
password: *****
host: 127.0.0.1
port: 3306
gem文件中的MySQL2:
gem 'mysql2', '~>0.3.10'
所以当输入:http://localhost:3000/controller/view
时,我得到:ActiveRecord :: ConnectionNotEstablished
我还能包括哪些有用的内容?
提前致谢。
答案 0 :(得分:1)
查看你的/etc/mysql/my.cnf
并检查mysql deamon的绑定地址。它可能不会绑定到任何IP。然后它将使用unix套接字,这比ip连接更快,...
绑定地址的选项名称为bind-address
,如果它不匹配则不会绑定到任何地址。还要查看socket
,它指定了unix套接字的路径。你可以在database.yml
development:
adapter: mysql2
encoding: utf8
database: *****_dev
username: ****
password: *****
socket: /path/to/the/socket/mysql.sock
那应该为你做,...