我正在尝试运行一个RoR应用程序,它似乎忽略了我的用户名和密码,如果它不是root,有什么想法吗?
如果配置如下,则可以:
development:
adapter: mysql2
database: dbname
user: root
password: root_password
pool: 5
timeout: 5000
但是,如果它是使用非root用户设置的,则会失败并显示消息`connect':用户'root'@ accesshost'拒绝访问(使用密码:YES)(Mysql2 :: Error) )
development:
adapter: mysql2
database: dbname
user: username
password: username_password
pool: 5
timeout: 5000
mysql -uusername -p<username password> <dbname>
连接没有任何问题。指定host
或hostname
无法解决问题。
更新
的database.yml
development:
adapter: mysql2
database: dbname
user: root
# username
password: root_password
# username_password
pool: 5
timeout: 5000
production:
adapter: mysql2
database: dbname
user: username
password: username_password
pool: 5
timeout: 5000
运行RAILS_ENV=development bundle exec rails c
Loading development environment (Rails 3.2.11)
irb(main):001:0>
答案 0 :(得分:2)
我的database.yml已过时(设置不正确)。 user
不是正确的密钥,而是username
。
development:
adapter: mysql2
database: dbname
username: root
# username
password: root_password
# username_password
pool: 5
timeout: 5000
production:
adapter: mysql2
database: dbname
username: username
password: username_password
pool: 5
timeout: 5000