Linux mysql password change

Reference: hardships, can swallow a thousand more WU

 

Bahrain recently mysql, mysql password want to change it, read some forums, will total about several modifications

1, a first embodiment, the outer modified mysql

-u root -p password mysqladmin " test123 " 
the Enter password: [Enter the old password]

 2, the second way, which is to be modified in mysql

-uroot-MySQL - P 
 the Enter password:] [enter the original password 
 MySQL > use MySQL; 
 MySQL > Update User SET password = PASSWORD ( "New Password " ) WHERE User = ' the root ' ; 
MySQL> the flush privileges; MySQL
> Exit;

But there are exceptions, is mysql 5.7 and above can not be used, the following operations

 mysql> update user set authentication_string=passworD("新密码") where user='root';
mysql> flush privileges;
mysql> exit;

3. The third method is to forget their password

 First get the operating system root privileges, and then kill off MySQL service, or manually stop away, I recommend using a manual stop

 #service mysql stop

Then execute

 # mysqld_safe --skip-grant-tables &

& Means running in the background, is not running in the background, then just open a terminal bar. Then change your password to log mysql

 # mysql
 mysql> use mysql;
 mysql> UPDATE user SET password=password("test123") WHERE user='root';   
mysql> flush privileges;
mysql> exit;

// Note mysql5.7 above problems

 

If you are a regular user can not connect mysql, this can help you solve

Grandpa, please inside

Note: It is to set the password here becomes 0000 (password), you want to set yourself.

Guess you like

Origin www.cnblogs.com/cheneyboon/p/11530876.html