Three easy-to-use solutions for modifying the root password of MySQL

Source: Internet
Author: User

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

 
 
  1. mysql -u root  
  2. mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’newpass’); 

Method 2: Use mysqladmin

 
 
  1. mysqladmin -u root password “newpass” 

If the root user has set a password, use the following method:

 
 
  1. mysqladmin -u root password oldpass “newpass” 

Method 3: Use UPDATE to directly edit the user table

 
 
  1. mysql -u root  
  2. mysql> use mysql;  
  3. mysql> UPDATE user SET Password = PASSWORD(’newpass’) WHERE user = ‘root’;  
  4. mysql> FLUSH PRIVILEGES; 

When the root password is lost

 
 
  1. Mysqld_safe-skip-grant-tables &
  2. Mysql-u root mysql
  3. Mysql> UPDATE user SET password = PASSWORD ("new password") WHERE user = 'root ';
  4. Mysql> flush privileges;
  5. Mysql-uroot-p (enter the mysql root Password)

Configure the MySQL administrator password:

 
 
  1. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.