mysql错误2002的解决办法 ERROR 2002 (HY000) mysql.sock(2)

时间:2022-09-19 21:39:12

mysql安装错误ERROR 2002 (HY000)解决办法

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)


问题解决过程,执行以下命令,看提示信息
#/usr/bin/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h controller password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!
执行
#/usr/bin/mysqld_safe &
执行完成MySQL2002错误就没有了,接着简单设置MySQL密码
#/usr/bin/mysqladmin -u root password 'new-password'
高级设置
Alternatively you can run:
#/usr/bin/mysql_secure_installation

重启MySQL服务,现在可以用密码登录MySQL,而不会出现error 2002了。
虽然不知道具体的错误原因,但是以上办法的确可以决解问题。