您的当前位置:首页正文

修改MySQL数据库root用户名和密码

来源:华佗小知识
更改密码:

mysql -u root -p
Enter password:***
mysql>use mysql; 选择数据库
Database changed
mysql> update user set password=password("newPassword") where user='root'; 将root用户的密码修改为新的密码
mysql> flush privileges; 刷新权限
mysql> quit;

更改用户名:

mysql -u root -p
Enter password:***
mysql> use mysql; 选择数据库
Database changed
mysql> update user set user="newUserName" where user="root"; 将用户名为root的改为新用户名
mysql> flush privileges; 刷新权限
mysql> exit;