mysql -u root -p
Then I created a new user bill with host %
CREATE USER 'bill'@'%' IDENTIFIED BY 'passpass';
Granted all the privileges to user bill:
grant all privileges on . to 'bill'@'%' with grant option;
Then I exit from root user and try to login with bill:
mysql -u bill -p
entered the correct password and got this error:
ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
錯誤原因:
mysql.user表中存在一條user=''的記錄,導致登錄時首先匹配到這條記錄,所以無法登錄。
解決辦法:
刪除掉這條用戶記錄,即操作語句:DELETE FROM mysql.user where user='';