Today, I logged into the server and prepared to modify some things in the database. But after entering the password, I cannot enter the database and an error message is displayed, as shown below Even after confirming that the password is correct, I still cannot enter the database. I found a solution on the Internet and wrote it down for reference. Solution: The overall idea is: (under Linux system) shut down the MySQL service, configure MySQL to log in without a password, then reset the password, refresh the database, remove the previous configuration, and restart MySQL. 1. Shut down the MySQL service, command: service mysqld stop. Find your MySQL configuration file. The location of each person's installation may be different. For example, my configuration file is as follows 2. In the directory where the configuration file is located, use the vim command to edit it, command: vim my.cnf Enter vim editing mode again, press insert, and add skip_grant_tables at the specified location in the figure below, as shown in the figure below 3. Save and exit the configuration file, command: ① shift + semicolon ② enter wq ③ press Enter. This configures password-less login. Start the database, command: service mysqld start. Enter the database, type in the command line: mysql -u root -p, and then press Enter to enter the database O(∩_∩)O 4. After entering the database, set a new password for the database. If you still want to use the previous password, you can set it back to the previous password. This is also possible. Command (press Enter after each command): ① use mysql; ② update user set password=password("new password") where user="root" ③flush privileges; ④ quit; Note: The second command is suitable for MySQL 5.6 and earlier versions. There is no password field after MySql5.7. You should execute update user set authentication_string = password('newpassword') where user='root'; to change the password. 5. After the database password is changed, comment out the modified part of the original database configuration file by adding a # sign before the statement. 6. Restart the database service, command: service mysqld restart . At this time, you can log in to the database with the password you just set~\(≧▽≦)/~ The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Weird and interesting Docker commands you may not know
>>: Example of using store in vue3 to record scroll position
Table of contents 1. Introduction 2. Scenario 3. ...
Preface In the past, I always switched Python ver...
Table of contents VMware BurpSuite 1. Virtual mac...
1. Change password 1. Modify the password of ordi...
Creating a Vue 3.x Project npm init @vitejs/app m...
This article is compiled with reference to the My...
Generally, on national days of mourning, days of ...
Solution to the problem of automatic disconnectio...
Seeing the recent popular WeChat tap function, I ...
Basic syntax of the table <table>...</tab...
1. Background When the Docker service is started,...
The async_hooks module is an experimental API off...
I have nothing to do recently, so I tinker with C...
1. Unzip MySQL 8.0.16 The dada folder and my.ini ...
<br />The website access speed can directly ...