Linux mysql how to change the root password

  
                

Speaking of the root password, many people think of the root password of the computer system, in fact, mysql also has a root password, then in the Linux system, how to modify the root password in mysql? Especially what should I do if I forget the root password?

mysql by logging systems:

code is as follows

# mysql -uroot -p

Enter password: Enter the old password] [< Br>

mysql"use mysql;

mysql" update user set password=passworD(“test”) where user=’root’;

mysql "flush privileges;< Br>

mysql" exit;

Outside the mysql system, use mysqladmin:

The code is as follows

# mysqladmin -u root -p password “test123″< Br>

Enter password: [Enter the original password]

Forget the password of the original myql root:

First of all, you must have the root privileges of the operating system. If you do not have the root privileges of the system, first consider the root system and then follow the steps below.

Similar to the safe mode login system, it is recommended to say pkill mysql, but I do not recommend it. Because when you execute this command, it will lead to such a situation:

The code is as follows

/etc/init.d/mysqld status

mysqld dead but subsys locked< Br>

So even if you start mysql in safe mode, it may not be useful, so it is generally /etc/init.d/mysqld stop, if you unfortunately use pkill first, then start and then stop .

Code is as follows

# mysqld_safe –skip-grant-tables &

&, means running in the background, no longer running in the background, then open a terminal Oops.

Code is as follows

# mysql

mysql use mysql;

mysql UPDATE user SET password=password(“test123“) WHERE user= ’root‘;

mysql "flush privileges;

mysql" exit;

## Originally mysql is not case-sensitive, but this is modified mysql The specific value of the mysql database should be noted.

The above is the introduction of Linux to change the root password of myaql, this article also details the mysql forget the root password modification method, I hope to help you.

Copyright © Windows knowledge All Rights Reserved