大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

怎么解决MySQL中的ERROR2002(HY000)报错问题-创新互联

本篇内容主要讲解“怎么解决MySQL中的ERROR 2002(HY000)报错问题”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么解决MySQL中的ERROR 2002(HY000)报错问题”吧!

成都创新互联公司成立与2013年,是专业互联网技术服务公司,拥有项目成都网站制作、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元平江做网站,已为上家服务,为平江各地企业和个人服务,联系电话:18982081108

[root@testmysql bin]# ./mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决方法:

由于mysql 默认的mysql.sock 是在/usr/local/mysql/data/mysql.sock,但linux系统总是去/tmp/mysql.sock查找,所以会报错

1.直接指定mysql通道

据我知道的(ps:我是菜鸟,请纠正),老版本(5.4之前)的是:/var/lib/mysql/mysql.sock

 在新版本中默认是在/usr/local/mysql/data/mysql.sock,具体的可以去查看my.cnf文件里面

[root@testmysql bin]# ./mysql --socket=/usr/local/mysql/data/mysql.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.4-m7 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>

2. 创建符号连接:

为mysql.sock增加软连接(相当于windows中的快捷方式)。

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock


eg:
root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@testmysql bin]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

插曲:有可能你在建立连接的时候出现下面的情况,
[root@testmysql bin]# ln -vs /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
ln: creating symbolic link `/tmp/mysql.sock': File exists
没关系,加上-f参数就可以了。-f的主要过程:先将同名的软链接dd删除,然后再创建硬链接dd

[root@testmysql bin]# ln -f /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
[root@testmysql bin]# ./mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.4-m7 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中的ERROR 2002(HY000)报错问题”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


网页名称:怎么解决MySQL中的ERROR2002(HY000)报错问题-创新互联
网站网址:http://dzwzjz.com/article/hcjge.html
在线咨询
服务热线
服务热线:028-86922220
TOP