您好,登錄后才能下訂單哦!
本篇內容主要講解“怎么解決MySQL中的ERROR 2002(HY000)報錯問題”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么解決MySQL中的ERROR 2002(HY000)報錯問題”吧!
[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)報錯問題”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。