Home  >  Article  >  Database  >  How to change the password of Mysql database? How to change password in Mysql database

How to change the password of Mysql database? How to change password in Mysql database

云罗郡主
云罗郡主Original
2019-01-22 14:20:268355browse



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
How to change the password of Mysql database? How to change password in Mysql database

as an administrator Open the console as my identity, I am win10, and after entering, it looks like this

How to change the password of Mysql database? How to change password in Mysql database

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

How to change the password of Mysql database? How to change password in Mysql databaseI 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
How to change the password of Mysql database? How to change password in Mysql database Stop the mysql service first, There are two methods
Use the command net stop mysql
How to change the password of Mysql database? How to change password in Mysql database The second method: win R enter services.msc and press Enter, then find mysql, right click to stop
How to change the password of Mysql database? How to change password in Mysql database

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
How to change the password of Mysql database? How to change password in Mysql 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

How to change the password of Mysql database? How to change password in Mysql database7. Show tables to view all tables, you will find a user table, which stores account information such as user name, password, permissions, etc.
How to change the password of Mysql database? How to change password in Mysql database

Enter select user,host,password from user; to view account information.
How to change the password of Mysql database? How to change password in Mysql database

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
1How to change the password of Mysql database? How to change password in Mysql database10. Check the account information again, select user,host,password from user; You can see that the password has been modified
1How to change the password of Mysql database? How to change password in Mysql database

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.
1How to change the password of Mysql database? How to change password in Mysql database








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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn