mysql to change the password method

change Password:

1. For example, you do not have root user password, you want to modify the password is 123456, the command is:

mysqladmin -u root password 123456

2. If you now have the root password (123456), then change the password as abcdef command is:

mysqladmin -u root -p password abcdef 

Note that you will ask your old password Enter the command, enter the old password after the command completes 123456, password change successful.

3. If you now have the root password (123456), then change the password as abcdef command is:

mysqladmin -u root -p123456 password abcdef (-p Do not pay attention to the back of the password and points

Open to write, to write together, or be wrong, wrong as shown below)

4. Use phpmyadmin, this is the easiest, and modify the mysql database user table,

 

But do not forget to use the PASSWORD function.

 

 

forget password:

Below we offer six different modifications mysql root user's password, and increase user mysql method.

method one 

Use phpmyadmin, this is the easiest, and modify the mysql database user table, 

But do not forget to use the PASSWORD function. 

Method Two 

Use mysqladmin, which is a special case of the previous statement. 

mysqladmin -u root -p password mypasswd 

After you enter this command, the original need to enter the root password, and then root password will be changed mypasswd. 

The command in the root to your user name, you can change your own password. 

Of course, if your connection is not on mysqladmin mysql server, or you can not execute mysqladmin, 

Then this method is ineffective. 

But not the password mysqladmin empty. 

The following methods are used in the mysql prompt, and must have mysql's root permissions: 

Method Three 

mysql> INSERT INTO mysql.user (Host,User,Password) 

VALUES('%','jeffrey',PASSWORD('biscuit')); 

mysql> FLUSH PRIVILEGES 

Rather it is to add a user, the user name jeffrey, the password for the biscuit. 

In the "mysql Chinese reference manual," there are examples of this, so I will write out. 

Note To use the PASSWORD function, and then also use the FLUSH PRIVILEGES. 

Method Four 

Method three and the same, but use the REPLACE statement 

mysql> REPLACE INTO mysql.user (Host,User,Password) 

VALUES('%','jeffrey',PASSWORD('biscuit')); 

mysql> FLUSH PRIVILEGES 

Method five 

Use SET PASSWORD statement, 

mysql> SET PASSWORD FOR jeffrey@"%" = PASSWORD('biscuit'); 

Quasi must also use PASSWORD () function, 

But no need to use FLUSH PRIVILEGES. 

Method six 

Use GRANT ... IDENTIFIED BY statement 

mysql> GRANT USAGE ON *.* TO jeffrey@"%" IDENTIFIED BY 'biscuit'; 

Here PASSWORD () function is unnecessary, does not need to use the FLUSH PRIVILEGES. 

Note: PASSWORD () [not] In the same manner as in the Unix password encryption password encryption purposes.

MySQL forgotten password solution

If MySQL is running, the first kill: killall -TERM mysqld. 

启动 MySQL :bin/safe_mysqld --skip-grant-tables & 

You may not need a password to enter the MySQL. 

Then there 

>use mysql

>update user set password=password("new_pass") where user="root";

>flush privileges;

Re kill MySQL, start MySQL using normal methods.

Method 1: Use SET PASSWORD command 
first log 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 
Format: mysqladmin -u username -p password old password new password 
example: mysqladmin -uroot -p123456 password 123 

method 3: UPDATE table directly edit user 
first logs on MySQL. 
MySQL> use MySQL; 
MySQL> Update User SET password = password ( '123') WHERE User = 'root' and Host = 'localhost'; 
MySQL> the flush privileges; 

Method 4: forget the root password, they can so  
to windows Case Study: 
MySQL service 1. Close running. 
2. Open a DOS window, go to the mysql \ bin directory. 
3. Enter mysqld --skip-grant-tables carriage. --skip-grant-tables means that the time to start MySQL service permission to skip the authentication table. 
4. 
5. Enter the mysql enter, if successful, will appear MySQL prompt>. 
6. Connect authority database: use mysql;. 
6. Change Password: update user set password = password ( "123") where user = "root"; ( Remember last semicolon). 
7. refresh permission (must step): flush privileges;. 
8. Quit quit. 
9. log off the system, re-entry, using the username root and the password just set up 123 new login.

Guess you like

Origin www.cnblogs.com/klb561/p/12152643.html