Solutions for forgetting the MySQL root password

Source: Internet
Author: User

I. MySQL password recovery method one

It is possible that your system does not have SAFE_MYSQLD programs (such as the Ubuntu OS I am using now, Apt-get installed MySQL),

The following method can recover 1. Stop mysqld;/etc/init.d/mysql stop (you may have other methods, stop mysqld running anyway)

2. Start MySQL with the following command to start without checking permissions;

Mysqld--skip-grant-tables & or Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &

3. Then log in to MySQL using the root user with a blank password; mysql-u root MySQL

4. Change the password of the root user;

mysql> Update Mysql.user Set Password=password (' NewPassword ') where user= ' root ' and host= ' root ' or host= ' locahost ';

mysql> flush Privileges;

Mysql> quit restart

Mysql/etc/init.d/mysql restart

#mysql-uroot-p

You can log in with the new password newpassword.

Two. MySQL password recovery method Two If you forget the root password of MySQL, you can reset it in the following ways:

1. Kill the MySQL process in the system; Killall-term mysqld

2. Start MySQL with the following command, starting without checking permissions; Safe_mysqld--skip-grant-tables &

3. Then log in to MySQL using the root user with a blank password; mysql-u root

4. Change the password of the root user;

mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';

mysql> flush Privileges;

Mysql> quit to restart MySQL,

#mysql-uroot-p

You can log in with the new password.

Solutions for forgetting the MySQL root password

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.