Modify the password of the Mysql user (root) under Linux

1. Own the root password of the original myql;


Method 1:
Outside the mysql system, use mysqladmin
mysqladmin -u root -p password "test123"
Enter password: [Enter the original password]

Method 2:
Log in to the mysql system,
mysql -uroot -p
Enter password: [Enter the original password]
mysql> use mysql;
mysql>  update user set password=password("test") where user='root';
mysql>  flush privileges;
mysql>  exit; II. Forgot the original myql root password; first of all, you must have root access to the operating system. If you don't even have root privileges on the system, consider the root system first and then follow the steps below. Similar to the safe mode login system, some people suggest that it is pkill mysql , but I don't recommend it. Because when you execute this command, it will cause this situation: /etc/init.d/mysqld status mysqld dead but subsys locked      







In this way, 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 it and then stop it.
mysqld_safe --skip-grant-tables &
& means running in the background. If it is no longer running in the background, open another terminal.
mysql
mysql>  use mysql;
mysql>  UPDATE  user  SET  password = password (" test123 ") WHERE  user =' root ';  mysql>  flush privileges; mysql>  exit; ##Originally mysql is case-insensitive, but this is The specific value of the mysql database in the modified mysql should be noted.  

                         

 

JAVA technical exchange group 532101200

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326641796&siteId=291194637