修改完mysql的配置文件/etc/my.cnf
将数据库路径datadir和socket修改到其他路径后
使用mysql_secure_installation时报错
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
这是因为脚本mysql_secure_installation中路径写死了
使用vi编辑脚本mysql_secure_installation
在make_config() {
echo "# mysql_secure_installation config file" >$config
echo "[mysql]" >>$config
echo "user=root" >>$config
esc_pass=`basic_single_escape "$rootpass"`
echo "password='$esc_pass'" >>$config
echo "socket=/otherdir/mysql/mysql.sock" >> $config
#sed 's,^,> ,' < $config # Debugging
}
中加入echo "socket=/otherdir/mysql/mysql.sock" >> $config一句
重新使用mysql_secure_installation安装