I have gone over dozens of articles related to such issues without solving mine.
MySQL 8 over CentOS 8, my.cnf file indicate the socket as following:
[mysqld]
datadir=/data/mysql8/mysql
socket=/data/mysql8/mysql/mysql.sock
But when I try to connect, mysql detect the old location of datadir
of socket file:
[root@db0 ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
While the running is mysql-server
not mysql-client
and the only config file used is the one mentioned in the question (only /etc/my.cnf
exists and all other files are not).
[root@db0 ~]# /sbin/mysqld --verbose --help | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
Also when I check the mysql config, I can see the wrong dir of socket file being selected.
[root@db0 ~]# mysqladmin variables
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!