关于mysql 2002错误的解决方法

本来今天是做主从复制的,但是不知道为什么直接上来就出现了2002错误,百思不得其解,哥们我锲而不舍的还在犯傻以为是配置的问题,改来改去花费的时间太长了,没办法上网看看吧,有很多解决方法都么有成功,太让我失望了,后来不经意发现有人提出是权限问题,但是没有解决方法啊,只能自己摸索了,最后不屑的努力下终于成功的搞好了,不知道是不是也有人发过

root@localhost mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@localhost bin]# ./mysqld_safe -u mysql
Starting mysqld daemon with databases from /usr/local/mysql/var
STOPPING server from pid file /usr/local/mysql/var/localhost.localdomain.pid

第一步:到/usr/local/mysql/var目录下

[root@localhost bin]#
[root@localhost bin]# cd /usr/local/mysql/var/

第二步:修改目录权限

[root@localhost var]# chown -R mysql:mysql /usr/local/mysql/var
[root@localhost var]# /usr/local/mysql/bin/mysqld_safe &
[1] 3040
[root@localhost var]# Starting mysqld daemon with databases from /usr/local/mysql/var
 

第三步:

[root@localhost var]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> Aborted
.

mysql>
 

成功

 

你可能感兴趣的:(mysql,linux,2002)