首页 > 代码库 > mysql连接报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket
mysql连接报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket
安装完mysql连接报错:
[root@localhost app]# mysql ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2) [root@localhost app]# mysql -uroot -p Enter password: ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)
分析:error
Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘
查询自己的 mysql.sock文件
发现自己的路径在
[root@localhost data]# find / -name mysql.sock /tmp/mysql.sock
则在 my.cnf 中添加指定 mysql.sock文件
[root@localhost data]# vim /etc/my.cnf [mysqld] socket=/tmp/mysql.sock
fack!! 重启mysql服务问题依旧存在
于是添加软连接
[root@localhost data]# mkdir -pv /var/lib/mysql mkdir: 已创建目录 “/var/lib/mysql” [root@localhost data]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock [root@localhost data]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.16 Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql>
问题解决!!!
疑问:在安装 mysql的时候已经通过-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 指定了,但为什么没有生效?
本文出自 “愿与您分享” 博客,请务必保留此出处http://pengjc.blog.51cto.com/9255463/1861088
mysql连接报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。