1. 程式人生 > >Lost connection to MySQL server at 'reading initial communication packet', system error: 104

Lost connection to MySQL server at 'reading initial communication packet', system error: 104

報錯

SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 104 "Connection reset by peer" 


PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused") ```
很奇怪,自從在阿里雲的伺服器掛載了一個新的雲磁碟,然後把mysql 存放目錄完全遷移,就總是報這個錯誤。

嘗試修改

MariaDB [(none)]> select Host,User from mysql.user where user='root';
+-----------+------+
| Host      | User |
+-----------+------+
| 127.0.0.1 | root |
| ::1       | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)

按照網上查詢到的資料,需要更改連結地址 127.0.0.1 改為localhost 。 只能看接下來是否還會有這樣的報錯了。