Get the App
SLTechnology News&Howtos  ›  Database  › 

What if MySQL forgets his password?

Shulou Source: shulou.com Published: 2022-05-31 18:48:10 10月14日 Update

This article introduces the knowledge of "how to forget your password in MySQL". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Windows:

1. Log in to the system with a system administrator.

two。 Stop the service of MySQL.

3. Enter the command window, and then go to the MySQL installation directory, for example, my installation directory is c:\ mysql, enter C:\ mysql\ bin

4. Skip permission check to start MySQL

C:\ mysql\ bin > mysqld-nt-- skip-grant-tables

5. Reopen a window, go to the c:\ mysql\ bin directory, and set the new password for root

C:\ mysql\ bin > mysqladmin-u root flush-privileges password "newpassword"

C:\ mysql\ bin > mysqladmin-u root-p shutdown

Replace newpassword with the password of the root you want to use, and the second command prompts you to enter the new password, repeating the password entered by the first command.

6. Stop MySQL Server and start Mysql in normal mode

7. You can link to Mysql with your new password.

Unix&Linux:

1. Log in to the system with root or a user running mysqld

two。 Use the kill command to end the process of mysqld

3. Start MySQL Server with the-- skip-grant-tables parameter

Www# mysqld_safe-- skip-grant-tables &

4. Set a new password for root@localhost

Www# mysqladmin-u root flush-privileges password "newpassword"

5. Restart MySQL

There is another way to delete the mysql table from the original database and then run scripts/mysql_install_db

If you forget mysql root's password, don't panic. You can recover by following a few steps as a super user in the operating system (UNIX's ROOT, not MYSQL's ROOT):

1. Stop mysql

/ etc/init.d/mysql stop or

Ps ax | grep-I mysql find all processes ID + kill pid

two。 Bypass authorization table to start

Safe_mysqld-- skip-grant-tables &

3. Direct access to mysql database

Mysql mysql

4. Modify the password

Update user set password = password ('mypassword') where user =' root'

After the above steps, restart mysql and try the password you just set, and you will find that it is successful.

This is the end of the content of "how to forget your password in MySQL". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Password command system directory new secret what to do content data database more steps user knowledge process input run practical panic success successful learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn Shulou Technology Redmi NVidia