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='';