我正在Rails5上使用mysql2gem。如果有帮助的话,我还使用aws cloud9ec2示例进行开发。
我得到一个错误:
$ RAILS_ENV=development bundle exec rake db:setup
rake aborted!
Mysql2::Error::ConnectionError:
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
这是我的database.yml文件:
development:
adapter: mysql2
socket: /var/mysql/mysql.sock
database: wagn_development
username: user
password: user
host: localhost
test:
adapter: mysql2
socket: /var/mysql/mysql.sock
database: wagn_test
username: user
password: user
host: localhost
production:
adapter: mysql2
socket: /var/mysql/mysql.sock
database: wagn_production
username: user
password: user
host: localhost
如何解决错误?
1条答案
按热度按时间1mrurvl11#
我相信这与rails无关。
您使用的是rds还是db在同一台机器上?
你读过这个或试过这些吗?我相信这是缓和了
无法通过套接字'/var/lib/mysql/mysql.sock'(2)连接到本地mysql服务器