centos7中Mysql修改密碼的幾種方法

修改密碼
root修改本身密碼
方法一:mysql

mysqladmin -uroot -p'123' password 'new_password' //123爲舊密碼

方法二:
在Mysql中sql

update mysql.user set authentication_string=password('Qianfeng123!') where user='root' and host='localhost';

方法三:
給哪一個用戶設置密碼,你要在哪一個用戶下執行ide

set password=password("new_password'')

上面方法將會在後面的版本remove,使用下面方法code

SET PASSWORD='new_password';  直接設置密碼

root修改其餘用戶密碼
方法一:rem

mysql> SET PASSWORD FOR user3@'localhost'=password('new_password');

上面的方法會在未來remove,使用下面的方法:string

mysql> SET PASSWORD FOR user3@'localhost'='new_password';

方法二:it

UPDATE mysql.user SET authentication_string=password('new_password')
    WHERE user='user3' AND host='localhost';

普通用戶修改本身密碼io

mysql> SET password=password('new_password');
mysql> select * from mysql.user\G
mysql> alter user 'wing'@'localhost' identified by 'Qianfeng123!@';
相關文章
相關標籤/搜索