怎么解決MySQL中的ERROR2002(HY000)報錯問題-創(chuàng)新互聯(lián)

本篇內(nèi)容主要講解“怎么解決MySQL中的ERROR 2002(HY000)報錯問題”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“怎么解決MySQL中的ERROR 2002(HY000)報錯問題”吧!

成都創(chuàng)新互聯(lián)公司成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站制作、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元平江做網(wǎng)站,已為上家服務(wù),為平江各地企業(yè)和個人服務(wù),聯(lián)系電話: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系統(tǒng)總是去/tmp/mysql.sock查找,所以會報錯

1.直接指定mysql通道

據(jù)我知道的(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. 創(chuàng)建符號連接:

為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

插曲:有可能你在建立連接的時候出現(xiàn)下面的情況,
[root@testmysql bin]# ln -vs /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
ln: creating symbolic link `/tmp/mysql.sock': File exists
沒關(guān)系,加上-f參數(shù)就可以了。-f的主要過程:先將同名的軟鏈接dd刪除,然后再創(chuàng)建硬鏈接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)報錯問題”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

名稱欄目:怎么解決MySQL中的ERROR2002(HY000)報錯問題-創(chuàng)新互聯(lián)
地址分享:http://bm7419.com/article14/hcjge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、品牌網(wǎng)站建設(shè)、網(wǎng)站維護、網(wǎng)站制作域名注冊、網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營