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: