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;  
  • 新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入时

      update mysql.user  set password=password('root') where user='root';

    提示

      ERROR 1054 (42S22): Unknown column 'password' in 'field list',

    原来是mysql数据库下已经没有password这个字段了,password字段改成了authentication_string

  • 所以更改语句替换为

      update mysql.user set authentication_string=password('root') where user='root';
  • 更改用户名:

      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

 

本文来源:https://www.cnblogs.com/renxiuxing/p/9053910.html

posted @ 2019-10-10 11:44  真善美_flower  阅读(437)  评论(0编辑  收藏  举报