在修改了my.cnf文件的路径之后,mysql 启动正常,端口监控正常,但是使用mysql命令登录时却报错:
ERROR 2002 (HY000): Can't connect to local MySQLserver through socket '/var/lib/mysql/mysql.sock'
mysql命令使用的是client的socket,之所以报错,是因为my.cnf没有重新定义,而原来的路径也已经被我移除。
cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[client]
socket=/data/mysql/mysql.sock ###添加这一行,mysql命令使用的是客户端的socket
[mysqld_safe]
log-error=/data/mysql/mariadb/mariadb.log
pid-file=/data/mysql/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
再重启,使用mysql时就没有问题了