centos7 in several ways to change the password Mysql

Change Password
root password to modify their own
method:

mysqladmin -uroot -p'123 'password' new_password '// 123 is the old password

Method two:
in the Mysql

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

Method three:
to which the user set a password, you have to execute in which user

set password=password(new_password'')

The above method will be later versions remove, use the following method

SET PASSWORD='new_password';  直接设置密码

root user password to modify other
method:

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

The above method will in future remove, use the following method:

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

Method Two:

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

Ordinary users to change their passwords

mysql> SET password=password('new_password');
mysql> select * from mysql.user\G
mysql> alter user 'wing'@'localhost' identified by 'Qianfeng123!@';

Guess you like

Origin blog.51cto.com/14482279/2432432
Recommended