首页 > CentOS > MySQL-5.5.27 运行mysql_secure_installation 出现ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) 解决方法
2012
08-08

MySQL-5.5.27 运行mysql_secure_installation 出现ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) 解决方法

CentOS 源码安装MySQL 5.5.27 完成之后,当我运行mysql_secure_installation来设置mysql 密码的时候出现以下提示

# mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

 

查看我们的mysql 目录的权限,也没有错

# ls -ll /usr/local/mysql/
total 76
drwxr-xr-x.  2 mysql mysql  4096 Aug  8 10:11 bin
-rw-r--r--.  1 mysql mysql 17987 Jul 21 01:38 COPYING
drwxr-xr-x.  4 mysql mysql  4096 Aug  8 10:10 data
drwxr-xr-x.  2 mysql mysql  4096 Aug  8 10:10 docs
drwxr-xr-x.  3 mysql mysql  4096 Aug  8 10:10 include
-rw-r--r--.  1 mysql mysql  7604 Jul 21 01:38 INSTALL-BINARY
drwxr-xr-x.  3 mysql mysql  4096 Aug  8 10:10 lib
drwxr-xr-x.  4 mysql mysql  4096 Aug  8 10:11 man
drwxr-xr-x. 10 mysql mysql  4096 Aug  8 10:11 mysql-test
-rw-r--r--.  1 mysql mysql  2552 Jul 21 01:38 README
drwxr-xr-x.  2 mysql mysql  4096 Aug  8 10:11 scripts
drwxr-xr-x. 27 mysql mysql  4096 Aug  8 10:11 share
drwxr-xr-x.  4 mysql mysql  4096 Aug  8 10:11 sql-bench
drwxr-xr-x.  2 mysql mysql  4096 Aug  8 10:11 support-files

 

再看我们的my.cnf 文件的配置

找到
socket=/var/lib/mysql/mysql.sock
修改一下路径
socket=/tmp/mysql.sock

再重起一下MySQL Ok,
还有一种方法,就是

# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

 

最后编辑:
作者:dnybz
这个作者貌似有点懒,什么都没有留下。