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 definition structure Examples C...
Environmental Statement Host OS: Cetnos7.9 Minimu...
1. Download MySQL Workbench Workbench is a graphi...
error message: ERROR 2002 (HY000): Can't conn...
Nginx (engine x) is a lightweight, high-performan...
This article example shares the specific code for...
The input box always displays the input history wh...
Table of contents 1. Leftmost prefix principle 2....
Sometimes we need to remotely run programs on the...
Let's first look at several ways to submit a ...
1. When ffmpeg pushes video files, the encoding f...
Preface: During database operation and maintenanc...
Table of contents Effects Documentation first ste...
Table of contents Use two-way binding data in v-m...
Table of contents 1. Function Introduction 2. Key...