mysql three ways to modify the password

Method 1: Use SET PASSWORD command
    first log MySQL, using the mysql client connections that comes with the mysql.
    Format: mysql> set password for the user name @localhost = password ( 'new password');
    examples: mysql> set password for root @ localhost = password ( '123');
    
Method 2: mysqladmin (because we have added the bin environmental variables, this also mysqladmin bin directory, so you can directly use the mysqladmin function, use it to change the password)

    On the introduction of mysqladmin: perform management operations is a client program. It can be used to configure and check the current status of the server, create and delete databases, change user passwords, etc. function, although many of the functions mysqladmin can get by using the built-in MySQL client mysql, but sometimes use mysqladmin operation would be more simple.
    Format: The new password mysqladmin -u username -p password old password
    example: mysqladmin -uroot -p123456 password 123  
    
Method 3: directly edit the user table of the mysql database automatically using UPDATE
    first log MySQL, connect mysql server.
    mysql> use mysql; use mysql mysql meant to switch to the library, which is all the user tables tables, and rights which are in the library, we entered into this database in order to modify the library table inside.
    mysql> update user set password = password ( '123') where user = 'root' and host = 'localhost'; wherein the foregoing password = password ( '123') password is variable, behind password mysql is provided to the cryptographic encryption, we better not exist plaintext password, right, where the user is a table with information about all of deposit mysql user.

    mysql> flush privileges; refresh permission, let it take effect, or do not take effect, modify unsuccessful.

Guess you like

Origin www.cnblogs.com/alex3174/p/11432106.html