今天发现mysql备份不正常,提示找不到mysql-5.1.57.socket

mysql 备份出错,但是网站运行正常

localhost:~# /usr/local/mysql/bin/mysqldump --lock-tables=FALSE -uroot -p webadb_com > /root/webabc.sql

Enter password:

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql-5.1.57.sock' (2) when trying to connect


查看mysql.socket

localhost:~# netstat -ln | grep mysql

unix 2 [ ACC ] STREAM LISTENING 492228776 /tmp/mysql-5.1.57.sock


查看mysql进程

localhost:~# ps aux|grep mysql

root 3638 0.0 0.0 7552 864 pts/2 S+ 10:45 0:00 grep --color mysql

root 23896 0.0 0.0 3956 292 ? S Sep07 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/db --pid-file=/var/run/mysqld/mysql-5.1.57.pid

mysql 24396 21.8 25.0 2745632 1013672 ? Sl Sep07 2739:05 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/data/db --user=mysql --log-error=/var/log/mysql/localhost.err.log --pid-file=/var/run/mysqld/mysql-5.1.57.pid --socket=/tmp/mysql-5.1.57.sock --port=3306


重启mysql

localhost:~# /etc/init.d/mysqld restart

MySQL manager or server PID file could not be found! ... failed!

Starting MySQL

..........................................................................................................Manager of pid-file quit without updating file. ... failed!



查看配置文件

AU02:/tmp# cat /etc/myconf/mysql/my.cnf |grep socket

socket = /tmp/mysql-5.1.57.sock


上面都排查了,没有错误,说明mysql运行正常的,偶然出现问题,应该考虑别的方面,后来想起来mysql.socket运行在/tmp,是一个临时文件存放区,重启会清空,ls /tmp/grep mysql-5.1.57.socket果然不存在,进行如下操作即可正常。

在/tmp创建一个mysql.socket 文件,再把属组,属主更改为mysql的即可

touch /tmp/mysql-5.1.57.sock

chown mysql.mysql /tmp/mysql-5.1.57.sock


你可能感兴趣的:(MySQL报错,mysql.socket)