【问题标题】:Can't connect to local MySQL server through socket tmp/mysql.sock无法通过套接字 tmp/mysql.sock 连接到本地 MySQL 服务器
【发布时间】:2012-07-20 00:33:09
【问题描述】:

刚刚尝试在终端 (flush_hosts) 中访问一些 mysqladmin 权限,我注意到套接字问题再次出现并出现错误

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

我目前没有运行任何服务器。

如何解决?

【问题讨论】:

  • 等等,你有没有运行服务器???
  • 如果您当前没有运行 MySQL 服务器,您希望如何连接到它?!
  • 当前没有服务器运行,我的意思是额外的服务器(例如 MAMP)。我曾尝试使用 mysqld 来获取消息“mysql.host 不存在” - 为这篇文章的写法表示歉意。

标签: macos mysql mysql.sock mysqladmin


【解决方案1】:

哇,你自己提到过,你“必须”运行一个可以连接它的服务器,请考虑:

root@debian:/etc/init.d# /etc/init.d/mysql stop
[ ok ] Stopping MySQL database server: mysqld.
root@debian:/etc/init.d# mysql 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@debian:/etc/init.d# /etc/init.d/mysql start
[ ok ] Starting MySQL database server: mysqld ..
[info] Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly..
root@debian:/etc/init.d# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.24-5 (Debian)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

【讨论】:

  • 感谢您的回复。如上所述,我的意思是没有其他服务器运行,例如 MAMP。我的 /etc/ 文件夹中也没有 init.d 文件,因此我无法执行涉及 init.d 的解决方案
【解决方案2】:

好的,看来在此过程中一定有一些混乱的配置。我从头开始安装最新的.DMG for MySQL,现在一切正常。如果你有 .sock 问题,我猜你最好的选择是重新安装 MySQL,它根本不需要很长时间。感谢您的帮助!

【讨论】:

    【解决方案3】:

    尝试删除database.yml 文件中的套接字字段,或者将其更改为mysql.sock 的正确路径(如果您知道它在您的机器中的位置)。

    【讨论】:

      猜你喜欢
      • 2011-11-10
      • 2011-12-12
      • 2013-01-27
      • 2019-02-28
      • 1970-01-01
      • 2014-03-28
      • 2013-11-12
      相关资源
      最近更新 更多