CentOS Install Mysql When you forget to set the root password can not login solution _mysql

Source: Internet
Author: User
Tags flush

Objective

Yesterday is a day to start MySQL prompts: The server quit without updating PID file , today after the installation of MySQL or the same error, and then recovered a /usr/my.cnf bit suddenly can start. (Obviously yesterday/usr/my.cnf is the default, there is a solution to change this file only to change)

Then there is no problem to set the root password, search a few methods can not, until you see the following method of a line.

Workaround One:

#/etc/init.d/mysql Stop 
# mysqld_safe--user=mysql--skip-grant-tables--skip-networking & 
# mysql-u root m Ysql 
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root '; 
mysql> FLUSH privileges; 
Mysql> quit 
#/etc/init.d/mysql Restart 
# mysql-uroot-p 
Enter Password: < Enter the new password newpassword> 

Workaround Two:

Use directly /etc/mysql/debian.cnf [client] the user name and password provided in the section of the file:

# mysql-udebian-sys-maint-p 
Enter Password: < Enter the password > 
mysql> UPDATE user SET password= of the [client] section PASSWORD (' NewPassword ') where user= ' root '; 
mysql> FLUSH privileges; 
Mysql> quit 
# mysql-uroot-p 
Enter Password: < Enter the new password newpassword> 

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can help, if there is doubt you can message exchange.

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.