MySQL root password forgotten solution under Linux

Source: Internet
Author: User

1. First verify that the server is in a secure state,The safest state is to operate on the console of the server and unplug the network cable.
2. To modify the login settings for MySQL:
 
   
  
  1. # vim/etc/my.cnf
Add one sentence to the paragraph in [mysqld]: Skip-grant-tables For example:
 
   
  
  1. [mysqld]
  2. skip-grant-tables
Save and exit Vim. 3. Restart Mysqld
 
   
  
  1. # /etc/init.d/mysqld restart
  2. Stopping MySQL: [ OK ]
  3. Starting MySQL: [ OK ]
4. Log in and modify the root password of MySQL
  
 
  1. # /usr/bin/mysql
  2. mysql> use mysql ;
  3. mysql> update user set password=password(‘new-password‘) where User=‘root‘;
  4. mysql> flush privileges ;
  5. mysql> \q
  6. Bye
5. Change MySQL login settings back
 
   
  
  1. # vim/etc/my.cnf
Delete the skip-grant-tables you just added in the paragraph [mysqld]Save and exit Vim. 6. Restart Mysqld
 
   
  
  1. # /etc/init.d/mysqld restart
  2. Stopping MySQL: [ OK ]
  3. Starting MySQL: [ OK ]


From for notes (Wiz)

MySQL root password forgotten solution under Linux

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.