MySQL 5.5 關閉資料庫報錯"Can't connect to local MySQL server through socket"

feelpurple發表於2016-05-21
MySQL 5.5 關閉資料庫報錯

[root@localhost ~]# /software/bin/mysqladmin -usystem -p'system' shutdown
/software/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/cluster_data/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/cluster_data/mysql.sock' exists!

報錯原因:
資料庫之前使用過其他的socket

解決方法:
關閉資料庫命令引數中,指定現有的socket名字

檢視現有的socket
[root@localhost ~]# ps -ef|grep mysql
root      2487  2462  0 08:13 ?        00:00:00 /bin/sh /software/bin/mysqld_safe --defaults-file=/mysql_data/cnf/my.cnf
mysql     3057  2487  0 08:14 ?        00:00:00 /software/bin/mysqld --defaults-file=/mysql_data/cnf/my.cnf --basedir=/software --datadir=/mysql_data/70005 --plugin-dir=/software/lib/plugin --user=mysql --log-error=/mysql_log/err.log --open-files-limit=10240 --pid-file=/mysql_data/70005/mysqld.pid --socket=/mysql_data/70005/mysql.sock --port=55057
root      3092  3026  0 08:14 pts/1    00:00:00 grep mysql

[root@localhost ~]# /software/bin/mysqladmin -?|grep sock
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
  -S, --socket=name   The socket file to use for connection.
socket                            /cluster_data/mysql.sock

正常關閉資料庫
[root@localhost ~]# /software/bin/mysqladmin -usystem -p'system' shutdown --socket=//mysql_data/70005/mysql.sock 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2104461/,如需轉載,請註明出處,否則將追究法律責任。

相關文章