Note: To crack the root password in MySQL5.7, you can skip password authentication and log in to the database, and directly modify the password in the table. However, you cannot modify the root password in this way in MySQL 8.0. You need to skip password authentication and log in to the database, set the root password to empty first, and then you can log in to the database and modify the root password. 1. Solution to forgetting the root password of MySQL 5.7 database [root@mysql01 ~]# mysql --version #Determine the MySQL version mysql Ver 14.14 Distrib 5.7.28, for linux-glibc2.12 (x86_64) using EditLine wrapper [root@mysql01 ~]# vim /etc/my.cnf #Edit the main configuration file [mysqld] #Write the following content under the mysqld line skip-grant-tables .................#Omit some content[root@mysql01 ~]# systemctl restart mysqld #Restart the MySQL service to make the configuration file effective[root@mysql01 ~]# mysql -uroot #Skip password verification and log in to the database directly#Change the root password to pwd@123 and refresh the permissionsmysql> use mysql; mysql> update user set authentication_string = passwoord('pwd@123') where user = 'root'; mysql> flush privileges; #Refresh privilegesmysql> exit #Configure password verification and log in with the new password [root@mysql01 ~]# vim /etc/my.cnf #Edit the main configuration file [mysqld] skip-grant-tables #Delete this line [root@mysql01 ~]# systemctl restart mysqld #Restart to make the changes take effect #You can successfully log in using the new password [root@mysql01 ~]# mysql -uroot -ppwd@123 2. Solution to forgetting the root password of MySQL 8.0 database [root@mysql01 ~]# mysql --version # View MySQL version mysql Ver 8.0.18 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL) [root@mysql01 ~]# vim /etc/my.cnf #Edit the main configuration file [mysqld] #Write the following content under the mysqld line skip-grant-tables .................#Omit some content[root@mysql01 ~]# systemctl restart mysqld #Restart the MySQL service to make the configuration file effective[root@mysql01 ~]# mysql -uroot #Skip password verification and log in to the database directly#Set the root password to emptymysql> use mysql mysql> update user set authentication_string='' where user = 'root'; mysql> flush privileges; mysql> exit # Enable password verification and re-login to the database [root@mysql01 ~]# vim /etc/my.cnf # Edit the main configuration file [mysqld] skip-grant-tables #Delete this line [root@mysql01 ~]# systemctl restart mysqld #Restart to make the changes take effect [root@mysql01 ~]# mysql -uroot #Log in to the database directly mysql> alter user root@localhost identified by 'pwd@111'; mysql> flush privileges; mysql> exit #Login test using the new password [root@mysql01 ~]# mysql -uroot -ppwd@111 Summarize The above is the solution to the forgotten root password of MySQL 5.7 and 8.0 version database introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Native js to implement a simple calculator
1. Service method Check the firewall status: [roo...
Table of contents Environmental Description Insta...
This article mainly introduces the example of imp...
Table of contents 1. Component bloat 2. Change th...
First, we need to use the transform-origin attrib...
The color presentation on a web page will be affec...
This article shares the specific code of js to ac...
Table of contents 1. Vue3 component communication...
Original code: center.html : <!DOCTYPE html>...
The elements in an HTML document are arranged one...
When using setinterval, it is found that it will ...
Take MySQL 5.7.19 installation as an example, fir...
Introduction to HTML page source code layout This...
Original link: https://vien.tech/article/157 Pref...
CSS style rule syntax style is the basic unit of ...