mysql - 无法通过套接字 '/tmp/mysql.sock' 连接到本地 MySQL 服务器 (2) (Mysql2::Error)

标签 mysql ruby-on-rails sockets

我在 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/

相关文章:

java - 基本 Java 套接字,服务器不能发送,客户端也不能接收任何东西

php - 在一封电子邮件中发送多行

php - 尝试使用表单和 php 进行 INSERT INTO 查询,但数据库未更新记录

mysql - 如何将选择子查询重构为联接?

css - 如何为 Ruby on Rails 中的所有 Controller 使用 application.css.scss?

c - 代理中的非阻塞套接字和 poll() 怪癖

java - JSP简单插入无法在类中运行

ruby-on-rails - rails : How to get the name of the previous action in controller

javascript - 如何知道访客来自哪里?

macos - 如何让 DNS 解析在 El Capitan 上的 Mac OS X `chroot` 内工作?