Install mysql-5.7.24-el7-x86_64, delete the previously initialized data, and after re-initialization, the following error occurs when entering mysql -uroot -p to log in to mysql, and the socket cannot connect to mysql: ERROR 2002 (HY000): Can
' t connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Method 1:
First look for the location of the mysql.sock file, if you can find it, just make a soft connection.
find / -name mysql.sock
Find the location of the mysql.sock file and then soft connect to /tmp/mysql.sock
ln -s /mysqldata/mysql/tmp/my.sock /tmp/mysql.sock
Method 2:
Modify the location of mysql.sock in the my.cnf configuration file, restart the mysql program, and the mysql.sock file will be generated in the new directory.