Heim >Datenbank >MySQL-Tutorial >ERROR 2002 (HY000): Can't connect to local MySQL server thr_MySQL

ERROR 2002 (HY000): Can't connect to local MySQL server thr_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:34:521234Durchsuche

bitsCN.com

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决

 

用XAMPP装装好mysql之后,mysql -uroot 连不上,报这个错误:

 

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 

 

在mysql的配置文件里,/opt/lampp/etc/my.cnf, 发现了这样的配置:

 

[java] 

# The following options will be passed to all MySQL clients  

[client]  

#password       = your_password  

port            = 3306  

socket          = /opt/lampp/var/mysql/mysql.sock  

  

# Here follows entries for some specific programs  

  

# The MySQL server  

[mysqld]  

user            = nobody  

port            = 3306  

socket          = /opt/lampp/var/mysql/mysql.sock  

  

 

 

原来mysql用的套接字文件是:/opt/lampp/var/mysql/mysql.sock于是建立了个软连接, 命令如下。不能建立硬链接,不知道为什么。

ln -s /opt/lampp/var/mysql/mysql.sock  /var/run/mysqld/mysqld.sock

 

现在可以用mysql -uroot命令登陆上了~
 

bitsCN.com
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:c++ 连接mysql 中文乱码_MySQLNächster Artikel:MySQL语句温习_MySQL