The following article describes how to modify the root password of MySQL, however, if you are not very clear about the specific operation scheme, you can get a basic understanding of it through the following articles.
Method 1: use the set password command
- mysql -u root
- mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’newpass’);
Method 2: Use mysqladmin
- mysqladmin -u root password “newpass”
If the root user has set a password, use the following method:
- mysqladmin -u root password oldpass “newpass”
Method 3: Use UPDATE to directly edit the user table
- mysql -u root
- mysql> use mysql;
- mysql> UPDATE user SET Password = PASSWORD(’newpass’) WHERE user = ‘root’;
- mysql> FLUSH PRIVILEGES;
When the root password is lost
- Mysqld_safe-skip-grant-tables &
- Mysql-u root mysql
- Mysql> UPDATE user SET password = PASSWORD ("new password") WHERE user = 'root ';
- Mysql> flush privileges;
- Mysql-uroot-p (enter the mysql root Password)
Configure the MySQL administrator password:
- sudo mysqladmin -u root password newpassword
The above content is an introduction to modifying the root password of MySQL. I hope you will get some benefits.
This article describes how to change the root password of MySQL. I hope it will help you in this regard.