MySQL數據庫更名改密碼

  • 更改密碼(老版本):html

    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,登陸時提示密碼錯誤,安裝的時候並無更改密碼,後來經過免密碼登陸的方式更改密碼,輸入時mysql

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

    提示sql

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

    原來是mysql數據庫下已經沒有password這個字段了,password字段改爲了authentication_stringshell

  • 因此更改語句替換爲數據庫

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

    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

 

本文來源:http://www.javashuo.com/article/p-pixhfbkg-mn.htmlui

相關文章
相關標籤/搜索