Connection Mysql error ERROR 2002 (HY000)

1.Mysql has been installed and DB driver has been installed successfully. Failed when trying to connect to the database

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

tried:

mysql start

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

mysql -uroot

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

mysql -h localhost

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

mysql -h 127.0.0.1

ERROR 2003 (HY000): Can"t connect to MySQL server on "127.0.0.1" (61)
then go to the temp folder where there is no target file at all

/tmp/mysql.sock

use the find command:

find / -name mysql.sock

both:

Permission denied

many people failed to find it on the Internet. Thank you

for asking for help.
May.16,2022

vi / etc/mysql.cnf

check whether the paths configured by socket under [mysqld] and [mysql] tags are consistent

restart mysql after modification

Menu