這個情況,很可能是你的user表裡,root使用者既有host為"localhost"的記錄,也有host為‘127.0.0.1’的記錄,而localhost設了密碼,127.0.0.1沒有密碼,如下:mysql> select host,user,password from mysql.user where host="localhost" or host="127.0.0.1";+-----------+------+-------------------------------------------+| host | user | password |+-----------+------+-------------------------------------------+| 127.0.0.1 | root | || localhost | | || localhost | root | *8EEA7450973A13B4053E781CE39B9874EBE2857F |+-----------+------+-------------------------------------------+3 rows in set (0.01 sec)mysql> 就有可能造成這種情況
這個情況,很可能是你的user表裡,root使用者既有host為"localhost"的記錄,也有host為‘127.0.0.1’的記錄,而localhost設了密碼,127.0.0.1沒有密碼,如下:mysql> select host,user,password from mysql.user where host="localhost" or host="127.0.0.1";+-----------+------+-------------------------------------------+| host | user | password |+-----------+------+-------------------------------------------+| 127.0.0.1 | root | || localhost | | || localhost | root | *8EEA7450973A13B4053E781CE39B9874EBE2857F |+-----------+------+-------------------------------------------+3 rows in set (0.01 sec)mysql> 就有可能造成這種情況