8.0 以上版本修改密码使用:
ALTER user 'root'@'localhost' IDENTIFIED BY '你的密码';
如:
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456'; mysql> FLUSH PRIVILEGES;
用以前的方法会报这个错:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
注意一定要有分号。