教程集 www.jiaochengji.com
教程集 >  数据库  >  mysql  >  正文 启动MYSQL提示:Can’t connect to MySQL through socket ‘/tmp/mysql.sock’

启动MYSQL提示:Can’t connect to MySQL through socket ‘/tmp/mysql.sock’

发布时间:2023-05-02   编辑:jiaochengji.com
教程集为您提供启动MYSQL提示:Can’t connect to MySQL through socket ‘/tmp/mysql.sock’等资源,欢迎您收藏本站,我们将为您提供最新的启动MYSQL提示:Can’t connect to MySQL through socket ‘/tmp/mysql.sock’资源
本文章来给大家介绍在启动MYSQL时突然启动不了,查看日志发现提示:Can’t connect to MySQL through socket ‘/tmp/mysql.sock’,后来百度了两种解决办法,有需要的朋友可参考。

启动MYSQL是出现以下错误:

[root@www ~]# /usr/local/webserver/mysql/bin/mysqladmin -u root -p 12345678
Enter password:
/usr/local/webserver/mysql/bin/mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111)’
Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!

解决方法:

 代码如下 复制代码

[root@www ~]# /usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.1.38-log Source distribution

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql>

mysql的参数说明:

/usr/local/webserver/mysql/bin/mysql –help | less

列举常用参数:

-u, –user=name     User for login if not current user.
-p, –password[=name]
                      Password to use when connecting to server. If password is
                      not given it’s asked from the tty.
-S, –socket=name   Socket file to use for connection.


另一种解决办法


我通过vim /etc/my.cnf,修改了[mysqld]选项下面的socket的值

 代码如下 复制代码
socket=/var/lib/mysql/mysql.sock

ok,mysqld可以启动了

接下来,是mysql启动不了,同样,vim /etc/my.cnf,添加了如下脚本:

[mysql]

 代码如下 复制代码
socket=/var/lib/mysql/mysql.sock

然后,mysqladmin启动不了,还是一样,在[mysqladmin]下面socket值设置为同样的路径
ok,可以启动了

您可能感兴趣的文章:
ERROR 2002 (HY000): Can't connect to local MySQL
PHP站点提示“/var/lib/mysql/mysql.sock”不存在的解决方法
Can't connect to local MySQL server through socket 问题的解决方法
php error Can't connect to local MySQL server...的解决方法
mysql.sock文件不见了问题的解决方法
Linux Apache Mysql PHP典型配置
mysql提示MySQL server has gone away导入时报错2006错误
php连接不上数据库
php不连接数据库
centos源码安装mysql-5.1.53的实例详解

[关闭]
~ ~