How MySQL changes password and user name
Change password (old version):
mysql -u root -p Enter password:*** mysql>use mysql; --选择数据库-- Database changed mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user=‘你的用户名‘; mysql> FLUSH PRIVILEGES; mysql> quit;
The newly installed MySQL5.7, the login prompt password error, when the installation did not change the password, and later through the password-free way to change the password, input
update mysql.user set password=password(‘root‘) where user=‘root‘;
Tips
ERROR 1054 (42S22): Unknown column ‘password‘ in ‘field list‘,
The original MySQL database has no password This field, password field changed to Authentication_string
So the change statement is replaced with
update mysql.user set authentication_string=password(‘root‘) where user=‘root‘;
change user name:
mysql -u root -p Enter password:*** mysql> use mysql; --选择数据库--Database changed mysql> update user set user="新用户名" where user="root"; --将用户名为root的改为新用户名-- mysql> flush privileges; --刷新权限-- mysql> exit
How MySQL changes password and user name