更改密码(老版本):html
mysql -u root -p
Enter password:***
mysql>use mysql; --选择数据库-- Database changed mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user='你的用户名'; mysql> FLUSH PRIVILEGES; mysql> quit;
新安装的MySQL5.7,登陆时提示密码错误,安装的时候并无更改密码,后来经过免密码登陆的方式更改密码,输入时mysql
update mysql.user set password=password('root') where user='root';
提示sql
ERROR 1054 (42S22): Unknown column 'password' in 'field list',
原来是mysql数据库下已经没有password这个字段了,password字段改为了authentication_stringshell
因此更改语句替换为数据库
update mysql.user set authentication_string=password('root') where user='root';
更改用户名:bash
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
ui