修改mysql数据库的用户名和密码

来源:互联网 发布:java 文本输入框 编辑:程序博客网 时间:2024/05/17 19:16
更改密码:
[html] view plain copy
  1. mysql -u root -p  
  2. Enter password:***  
  3. mysql>use mysql;  选择数据库  
  4. Database changed   
  5. mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user='你的用户名';  
  6. mysql> FLUSH PRIVILEGES;  
  7. mysql> quit;  



更改用户名:
[html] view plain copy
  1. mysql -u root -p  
  2. Enter password:***  
  3. mysql> use mysql;  选择数据库  
  4. Database changed  
  5. mysql> update user set user="新用户名" where user="root";    将用户名为root的改为新用户名  
  6. mysql> flush privileges;    刷新权限  
  7. mysql> exit