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

  • 相关阅读:
    Sizzle之tokenize
    直转字符串为数组
    Sizzle前奏
    (242-528)
    (177-240)
    (92-176)
    (63~91)
    一些变量(39~62)
    mysql导入导出sql文件
    vim编辑器的一些操作
  • 原文地址:https://www.cnblogs.com/renxiuxing/p/9053910.html
Copyright © 2011-2022 走看看