ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

centos7.5 安装mysql数据库报错

问题:

[root@db04-54 scripts]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS! 
[root@db04-54 scripts]# systemctl start mysqld
[root@db04-54 scripts]# mysql -uroot -p123
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决方法:

[root@db02-52 scripts]# sed -i 's#/usr/local#/application#g' /etc/init.d/mysqld /application/mysql/bin/mysqld_safe