"Pure dry goods, small tricks" What about forgetting the MySQL user password?

Source: Internet
Author: User

What if I forgot my MySQL user password?

In the information society, it is a precondition for scientific research and decision management to fully and effectively manage and utilize all kinds of information resources. Database technology is the core of information system, such as management information System, office automation system, decision support system, and is an important technical means for scientific research and decision-making management.

Database, is itself visible as electronic file cabinets-storage of electronic files of the premises, users can file data in the new, interception, update, delete and other operations.

A database is a collection of data that is stored in a certain way, shared for multiple users, has the smallest possible redundancy, and is separate from the application.

That is, then there will be a database management data management users, users will have passwords, and sometimes will inevitably encounter forgotten management user password situation, then the user's password if accidentally lost what to do?

Here's a crossing to you about a forgotten MySQL user password:
First of all, we usually log in to the MySQL method as follows

[Email protected] ~]# mysql-u root-p
Enter Password://Enter the password here
Mysql>//will be able to log into MySQL database properly

But what if you forget your password?

Don't Panic!

Let's simulate the experiment:

First, stop the MySQL service and check if MySQL is over

[[email protected] ~]# systemctl stop mysqld.service [[email protected] ~]# netstat -ntap | grep 3306//可以看到3306端口已经没有服务进程了

Two, skip password Authentication login MySQL

[[email protected] ~]# mysqld --skip-grant-tables;    //跳过密码验证
此时重新开启一个终端,进行登录MySQL[[email protected] ~]# mysql -u root    //进行登录MySQLmysql>      //这里可以看到已经登录MySQL了然后进行密码的修改mysql> update mysql.user set authentication_string=password (‘abc123‘) where user=‘root‘;     //修改root用户的密码为abc123Query OK, 1 row affected, 1 warning (0.01 sec)Rows matched: 1  Changed: 1  Warnings: 1mysql> flush privileges;    //刷新,使新的密码设置生效Query OK, 0 rows affected (0.00 sec)mysql> exit     //退出MySQLBye此时我们在使用修改后密码abc123尝试登录[[email protected] ~]# mysql -u root -p Enter password:    //这里输入abc123mysql>     //就可以看到成功登录了

If you really accidentally forgot your MySQL database user's password, hope can help you!!!

"Pure dry goods, small tricks" What about forgetting the MySQL user password?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.