我正在尝试运行一个 RoR 应用程序,如果它不是 root,它似乎忽略了我的用户名和密码,有什么想法吗?
如果配置如下,它可以工作:
development:
adapter: mysql2
database: dbname
user: root
password: root_password
pool: 5
timeout: 5000
但是,如果使用非 root 用户设置,则会失败并显示消息`connect': Access denied for user 'root'@'localhost' (using password: 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
不修复它。
更新
数据库.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>