溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mysql.sock丟失后如何連接數(shù)據(jù)庫(kù)

發(fā)布時(shí)間:2020-07-19 01:08:04 來(lái)源:網(wǎng)絡(luò) 閱讀:939 作者:達(dá)日來(lái) 欄目:MySQL數(shù)據(jù)庫(kù)


防偽碼:沒(méi)有相當(dāng)程度的孤獨(dú)是不可能有內(nèi)心的平和。

【現(xiàn)象】

mysql.sock被刪除,導(dǎo)致無(wú)法連接數(shù)據(jù)庫(kù)。

[root@MySQL-01 ~]#mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

提示無(wú)法通過(guò)mysql.sock連接MySQL server。


解決

方案一:重啟數(shù)據(jù)庫(kù)會(huì)重新創(chuàng)建mysql.sock。

方案二:若暫時(shí)無(wú)法重啟數(shù)據(jù)庫(kù),可以通過(guò)TCP協(xié)議連接數(shù)據(jù)庫(kù)。

MySQL默認(rèn)使用的是UNIX套接字文件連接,而不是TCP/IP從。MySQL4.1開(kāi)始,可以用--protocol=TCP|SOCKETPIPE|MEMORY指定選項(xiàng)連接數(shù)據(jù)庫(kù)。

[root@MySQL-01 ~]#mysql -uroot -p --protocol=TCP
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16127
Server version: 5.6.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI