MySQL root password forgotten solution _ MySQL

Source: Internet
Author: User
Summary in many cases, the default password of the root user is not blank after mysql is installed. in this case, you need to log on to mysql to reset the password. Step 1: Check the root. mysql_secret file to install mysql. a random password is generated for the first time. you can use this password to log on.

In many cases, the default password of the root user is not blank after mysql is installed. in this case, you need to log on to mysql to reset the password.

Procedure

Method 1: view the/root/. mysql_secret file

The first time mysql is installed, a random password is generated. you can log on with this password. the random password has been generated and can be found in '/root/. mysql_secret.

Method 2: Use mysqladmin

Mysqladmin cannot change password

Mysqld_safe -- skip-grant-tables &

Mysql-uroot-p

Use mysql;

Update user set password = PASSWORD ("newpassword") where user = "root ";

Flush privileges;

Quit

Method 3: Add "skip-grant-tables"

Add "skip-grant-tables" in the/etc/my. cnf [mysqld] configuration section"

Restart mysql service

Service mysqld restart

Log on to mysql

Mysql-uroot-p mysql

Use mysql;

Update user set password = password ("password") where user = 'root ';

Update

Flush privileges;

Delete "skip-grant-tables" in the/etc/my. cnf [mysqld] configuration section"

Restart mysql service

Service mysqld restart

Log on with the new password

Mysql-uroot-p

After the PASSWORD is changed, the first logon ERROR may be 'error 1820 (HY000): You must set password before executing this statement '. You need to change the current logon PASSWORD again.

Change current user password

Set password = PASSWORD ('20140901 ')

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.