mysql怎樣更改密碼和用戶名
阿新 • • 發佈:2018-05-18
原來 authent col exit root column 密碼錯誤 -- sql數據庫
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
mysql怎樣更改密碼和用戶名