zoukankan      html  css  js  c++  java
  • mysql怎样更改密码和用户名

    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
      
    • 更多精彩内容,请关注微信关注公众号 明叶师兄的学堂

  • 相关阅读:
    msyql多个or,and,
    mysql中 where in 用法详解
    history.back(-1)和history.go(-1)的区别
    经典 mysql 28道题
    企业案例(二):增量恢复案例
    企业案例(一):由于mysql sleep线程过多小故障
    mysql数据库恢复
    binlog介绍
    mysql 数据库备份
    docker入门与实践
  • 原文地址:https://www.cnblogs.com/renxiuxing/p/9053910.html
Copyright © 2011-2022 走看看