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

$ mysql -u -p 提示:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
解决方法:

  • 检查文件/var/run/mysql/mysqld.sock是否存在。若不存,则进行手动创建:$ touch /var/run/mysqld/mysqld.sock
  • 更改文件权限,使得MySQL进程可以使用这个文件:chown mysql /var/run/mysqld/mysqld.sock
  • 重启MySQL服务:service mysql restart 或者 /etc/init.d/mysql restart

参考:https://cloud.tencent.com/developer/ask/35881

你可能感兴趣的:(Web,Service,mysql,数据库,database)