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
本文出自 “吾心” 部落格,請務必保留此出處http://leeforget.blog.51cto.com/6950397/1297570