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

Posted

技术标签:

【中文标题】ERROR 2002 (HY000): Can\'t connect to local MySQL server through socket\'/var/run/mysqld/mysqld.sock\' in ubuntu 18.04 LTS【英文标题】:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' in ubuntu 18.04 LTSERROR 2002 (HY000): Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock' in ubuntu 18.04 LTS 【发布时间】:2021-07-25 13:56:04 【问题描述】:

当我运行命令时

mysql -u root -p

我收到以下错误消息:

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

我从相关文章中查看了一些解决方案,但没有任何效果! 我尝试重新安装mysql,问题将暂时解决,但稍后再次弹出相同的错误消息 请帮忙!

【问题讨论】:

【参考方案1】:

是的,如果在相应路径中缺少 mysqld.scok,它将显示如下 所以请在下面尝试 1. 转到 opt/lamp/var/mysql/ 2. 右键单击​​ mysql.sock 和 -> makelink mysql.sock 3.剪切复制链接粘贴到root/var/run/create mysql文件夹,粘贴复制文件名重命名mysqld.sock

试试这个并用逗号重新启动 php 服务器 /opt/lamp/lamp 重启

试试这个,这对我有用

【讨论】:

当我尝试转到 opt/lamp/var/mysql/ 时,我收到的消息是“opt/lamp/var/mysql/:没有这样的文件或目录”

以上是关于ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock' 的主要内容,如果未能解决你的问题,请参考以下文章

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

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

FreeBSD 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) when I

尝试了一切仍然得到 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (

尝试了一切仍然得到 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (