Reset the root password of mysql in linux

Source: Internet
Author: User
I believe that when you forget your password, you cannot remember it. we will reset the password in the fastest and most direct way, this article mainly introduces how to reset the root password of mysql in linux. For more information, see mysql database, however, we often make a very low-level small mistake, and small editors often make the mistake. suddenly we forget the mysql root password, and then it will cause a series of troubles, the following section describes how to reset the root password in the linux operating system.
Method/step
Step 1: Check whether the operating system has a mysql database installed. run the command dpkg -- list | grep mysql in the debian operating system, for example:


First, check whether the root user password has been forgotten. enter the command mysql-uroot-p, for example:

Tragedy: The root user password of the database is forgotten. reinstalling is not a benefit. the following code tells you how to skip security verification and change the password. first, close the mysql service in the process, for example:


Start mysql in an abnormal way,/usr/local/mysql/bin/mysqld_safe-skip-grant-tables &
For example:


In this way, you do not need a password to enter mysql,/usr/local/mysql/bin/mysql-u root-p (you can press enter directly when entering the password), such:

Then, we will> use mysql;> update user set password = password ("enter new password") where user = "root";> flush privileges; re-kill the mysql process, start mysql in a normal way. everything is OK, as shown in the following figure:

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.