【发布时间】:2012-07-09 22:21:36
【问题描述】:
我正在设置一个基本的 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
我还可以添加哪些有用的信息?
提前致谢。
【问题讨论】:
-
如果将 127.0.0.1 替换为 localhost 是否有效?还有什么版本的Rails? 3.2.6?
-
如果我将 127.0.0.1 替换为 localhost,如果我尝试运行 rake db:migrate,则会收到套接字错误。使用 127.0.0.1 rake db:migrate 运行没有错误。另外,我在rails 3.2.2上。谢谢。
-
你安装了apache和mysql吗? localhost之后的结果是什么
标签: mysql ruby-on-rails