Solution to forgetting MySQL password: [root@localhost ~]# mysql -uroot -p ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) If this happens, it's usually because MySQL is not up. [root@localhost ~]# mysql -uroot -p ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) When this happens, it is usually because the password is entered incorrectly. Solution: 1. Stop MySQL [root@localhost ~]# service mysqld stop Stopping mysqld: [ OK ] 2. Modify the configuration file and add the following content to the last line skip-grant-tables //Skip authorization and enter the database directly 3. Restart MySQL [root@localhost ~]# service mysqld start [root@localhost ~]# mysql -uroot -p mysql> 4. Reset the password for MySQL mysql> use mysql //The password is stored in MySQL, you need to enter mysql> desc user; //View the fields in the user table. Passwords are generally stored in the password table. +------------------------+-----------------------------------+------+-----+-----------------------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+-----------------------------------+------+-----+-----------------------+-------+ | Host | char(60) | NO | PRI | | | | User | char(16) | NO | PRI | | | | Password | char(41) | NO | | | | mysql> update user set password=password('passw0rd') where user="root"; //Set the password to passw0rd mysql> flush privileges; // refresh 5. Then log out and log in again [root@localhost ~]# mysql -uroot -ppassw0rd mysql> 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:
|
<<: Sample code for deploying Spring-boot project with Docker
>>: Introduction to the common API usage of Vue3
When we do CSS web page layout, we all know that i...
Preface As we all know, the nginx configuration f...
On a whim, I wrote a case study of a small ball b...
1. Use pseudo-classes to display half of the Bord...
I usually use nginx as a reverse proxy for tomcat...
Interviewer: Have you read the source code of Vue...
This article introduces the method of using CSS3 ...
Table of contents Preface Cause analysis and solu...
MySQL previously had a query cache, Query Cache. ...
Introduction Based on docker container and docker...
Global Object All modules can be called global: r...
I just finished installing MySQL 5.7.19 in the ea...
1. MYSQL index Index: A data structure that helps...
Pure CSS3 makes a butterfly flapping its wings, s...
Result: html <nav id="nav-1"> <...