通过命令行进入mysql
更改密码:
mysql -u root -p
Enter password:***
mysql>use mysql; 选择数据库
Database changed
mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user='你的用户名';
mysql> FLUSH PRIVILEGES;
mysql> quit;
出现Unknown column 'password' in 'field list'
采用如下语句来更新,因为新版本mysql采用authentication_string替代了password字段
update mysql.user set authentication_string=password('root') where user='root' ;
flush privileges;
quit;
即可
更改用户名:
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