防偽碼:沒有相當程度的孤獨是不可能有內(nèi)心的平和。
【現(xiàn)象】
mysql.sock被刪除,導(dǎo)致無法連接數(shù)據(jù)庫。
[root@MySQL-01 ~]#mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)提示無法通過mysql.sock連接MySQL server。
【解決】
方案一:重啟數(shù)據(jù)庫會重新創(chuàng)建mysql.sock。
方案二:若暫時無法重啟數(shù)據(jù)庫,可以通過TCP協(xié)議連接數(shù)據(jù)庫。
MySQL默認使用的是UNIX套接字文件連接,而不是TCP/IP從。MySQL4.1開始,可以用--protocol=TCP|SOCKETPIPE|MEMORY指定選項連接數(shù)據(jù)庫。
[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>另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。