用二进制版本的安装包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。