我在 Justhost 服务器上安装了 Rails 3 应用程序。我仍在努力,但有时我会收到此错误:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error)
我检查了类似的问题: here
我试过这个命令 mysqladmin variables | grep 套接字
得到这个错误
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'ecotec11'@'localhost' (using password: NO)'
不明白怎么会这样。因为我很长时间没有更改 database.yml 文件。
我检查过我的数据库状况良好,用户和密码相同。
我尝试使用 touch tmp/restart.txt
重启服务器,但没有成功!
最佳答案
尝试重新安装要启用的 mysql 包以设置您的配置。
sudo apt-get install mysql-server --reinstall
如果这不允许您重新配置您可以使用的包
sudo dpkg-reconfigure mysql-server
看看 DigitalOcean 如何配置你的 MySQL: https://www.digitalocean.com/community/articles/a-basic-mysql-tutorial
关于mysql - 无法通过套接字 '/tmp/mysql.sock' 连接到本地 MySQL 服务器 (2) (Mysql2::Error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22040841/