今天重启mysql失败:
as3:~# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
as3:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
as3:~# /usr/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
检查了 /var/run/mysqld/目录,里面没有mysqld.sock文件。其实这是由于mysql没有对于 /var/run/mysqld/目录写入文件的权限造成的。运行命令:
chown -R mysql:mysql /var/run/mysqld/ 即可解决问题。
相关帖子:http://briteming.blogspot.jp/2013/05/mysql-db.html
------------------------------------
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 问题的解决
as3:~# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
as3:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
as3:~# /usr/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
检查了 /var/run/mysqld/目录,里面没有mysqld.sock文件。其实这是由于mysql没有对于 /var/run/mysqld/目录写入文件的权限造成的。运行命令:
chown -R mysql:mysql /var/run/mysqld/ 即可解决问题。
相关帖子:http://briteming.blogspot.jp/2013/05/mysql-db.html
------------------------------------
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 问题的解决
MySQL重启时,提示
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
就说说解决办法吧:
root@zby:~# /etc/init.d/mysql restart 启动不了了
网上说可能是/var/run/mysqld/的权限问题,不过,我是通过apt-get install 安装的,不会出现此问题
root@zby:/var/run/mysqld# ls -la /var/run/mysqld/
drwxr-xr-x 2 mysql root 80 2011-05-25 09:25 ./
显示属主是mysql,没有问题
此时可以通过下面方法解决:
root@zby:/usr/bin# /usr/bin/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
…………
root@zby:~#/etc/init.d/mysql start
此时不出意外,/var/run/mysqld/下就有mysqld.sock文件了
root@zby:~# ls /var/run/mysqld/
mysqld.pid mysqld.sock
mysql_install_db 脚本的目的是生成新的MySQL授权表。它不覆盖已有的MySQL授权表,并且它不影响任何其它数据。如果你想要重新创建授权表,首先停止mysqld服务器(如果它正运行)