Below to share under Linux How to modify the MySQL user (root) password, in two cases: the first when the original MySQL root password, the second case to forget the original MySQL root password.
The modified users are listed as root.
First, the root of the original MySQL password;
Method One:
Outside the MySQL system, use the Mysqladmin
Copy CodeThe code is as follows:
# mysqladmin-u root-p Password "test123"
Enter Password: "Enter the original password"
Method Two:
By logging into the MySQL system,
?
1234567891011 |
# mysql -uroot -p Enter password: 【输入原来的密码】 mysql>use mysql; mysql> update user set password=passworD("test") where user=‘root‘; mysql> flush privileges; mysql> exit; |
Second, forget the original MySQL root password;
First, you must have root access to the operating system. If you do not have the root authority of the system, consider the root system before taking the following steps.
Similar to Safe Mode login system, it was suggested that Pkill MySQL, but I do not recommend ha. Because when you execute this command, it can result in a situation like this:
Copy CodeThe code is as follows:
/ETC/INIT.D/MYSQLD status
Mysqld dead but Subsys locked
So even if you are in Safe mode to start MySQL may not be useful, so generally so/etc/init.d/mysqld stop, if you unfortunate first use Pkill, then start a bit stop.
Copy CodeThe code is as follows:
# Mysqld_safe--skip-grant-tables &
&, that means running in the background, no longer running in the background, then open a terminal.
Copy CodeThe code is as follows:
# MySQL
mysql> use MySQL;
mysql> UPDATE user SET Password=password ("test123") WHERE user= ' root ';
mysql> flush Privileges;
Mysql> exit;
How to modify the MySQL user (root) password under Linux