Because I haven’t used the database on my laptop for a long time, and I forgot the password, so I can’t enter the database
I found a method, the modification was successful, record it. [Recommended tutorial: MySQL tutorial]
First find the bin directory under the mysql installation directory and copy the bin directory
as an administrator Open the console as my identity, I am win10, and after entering, it looks like this
Then this place cannot be directly switched to the bin directory of mysql, which is a little different from win7. An error will be reported, like this
I was also very confused at the time, but later I found that I need to type a cmd here before switching to the bin directory
Stop the mysql service first, There are two methods
Use the command net stop mysql
The second method: win R enter services.msc and press Enter, then find mysql, right click to stop
Next, go to the bin directory and enter the command mysqld –skip-grant-tables. This is to skip password verification. Next, you need to reopen a command window. The one just now cannot be used (knock on the blackboard, highlight the key points, and take notes in a small notebook). Down, you need to reopen the administrator command window) Enter the bin directory and enter mysql. At this time, you can enter the database
Use the command show databases; you can see the database content. The mysql library is where user names are saved. Enter use mysql; Select mysql database
7. Show tables to view all tables, you will find a user table, which stores account information such as user name, password, permissions, etc.
Enter select user,host,password from user; to view account information.
Change the root password, enter update user set password=password('root') where user='root' and host='localhost'; change the password to root here. Tip Query ok and the modification is completed
10. Check the account information again, select user,host,password from user; You can see that the password has been modified
Exit the command line , restart the mysql database, enter mysql -uroot -p in the bin directory and press Enter. You will be prompted to enter the password. At this time, log in with the new password and you can log in.
The above is the detailed content of How to change the password of Mysql database? How to change password in Mysql database. For more information, please follow other related articles on the PHP Chinese website!