开发者

Rails rake db:setup fails on server: Can't connect to local MySQL server through socket '/tmp/mysql.sock'

开发者 https://www.devze.com 2023-01-28 03:14 出处:网络
I am running rake db:setup on my server, and I am getting: Can\'t connect to local MySQL server through socket \'/tmp/mysql.sock\'

I am running rake db:setup on my server, and I am getting:

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

(I added RAILS_ENV=production)

This开发者_Python百科 is on a ubuntu, nginx, passenger, mysql setup.


Either MySQL isn't running, or it's not configured to put the sock-file in the right place. Run something like ps aux | grep mysql to check if it's running. If it's running and the error persists, check if the file /tmp/mysql.sock exists. You can configure it in /etc/mysql/my.cnf

On my ubuntu machine its configured to /var/run/mysqld/mysqld.sock. Either change your mysql settings, or change config/database.yml in your Rails app.


I had this issue and after trying everything I discovered that this occurs if you install mysql after you have installed rails.

Reinstalling rails solved the issue for me.

Of course this advice is only relevant if iain's answer doesn't solve your issue ;-)


If you dont have the file /tmp/mysql.sock, create a symlink to the actual socket file. You will have to locate it first, but mine was here:

/etc/mysql/my.cnf

That should fix it, as long as mysql is actually installed and running, check using this:

ps aux | grep mysql


I changed the sockets in /etc/mysql/my.cnf, then it worked fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消