ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

用二进制版本的安装包mysql5.6.21在Linux上安装Mysql,在my.cnf 中修改了socket的位置。

执行mysql_secure_installation,遇到找不到sock文件的错误。

 

$ 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)
Enter current password for root (enter for none):
Aborting!

Cleaning up...
Cleaning up...
Warning: Could not unlink .my.cnf.4231: No such file or directory
Warning: Could not unlink .mysql.4231: No such file or directory

google,有人说需要修改/bin/mysql_secure_installation,在make_config中添加socket,可能是版本不同的原因,

在mysql5.6.21 二进制版本中的mysql_secure_installation 并没有找到make_config.

 

再次查看错误,想想不就是找不到/tmp/mysql.sock 这个文件吗。修改my.cnf把socket的路径指导/tmp/mysql.sock 不就ok了吗。

但这样需要重启MYSQL,不是很不方便。 突然想到了Linux的软链接功能,试一把果然OK.

 

$ ln -s /db/mysql5.6/logs/mysql.sock /tmp/mysql.sock

再次执行mysql_secure_installation ,ok。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值