Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

I forgot my root password for MySQL. What should I do?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

When we install MySQL, the default root user does not have a password to log in to MySQL. What should we do when we set the password for the root user and forget the password when we log in again?

Local root password reset:

Ideas for solving the problem:

1. Modify the main configuration file / etc/my.cnf to set the authentication of the permission table to be skipped when logging in

2. Restart the service after setting it up

3. Do password-free login on the mysql-server server and update the password of root

4. Modify the / etc/my.cnf main configuration file again

5. Restart the service

6. Log in with a new password

Example:

Environment: centos7 system with MySQL database installed

Steps:

After centos7 installs the mariadb server, mysql enters the database and sets a password for root, and then exits the database

Set password reference blog: https://blog.51cto.com/14181896/2361492

After exiting the database, you cannot enter the database directly with the mysql command. At this time, the password of root is root. Suppose we do not remember the root password of mysql at present, as follows

1. Modify the main configuration file / etc/my.cnf to set the authentication of the permission table to be skipped when logging in

Insert skip_grant_table in the main configuration file

2. Restart the service, and you can access the mysql database without a password

3. Update the password for root

Update mysql.user set password=password ("127") where user='root' and host='localhost' # sets the password to 127,

Flush privileges; # Refresh permissions table

4. Exit the database, comment on the skip_name_table line of the main configuration file, and restart the service again

5. Log in to the database with the newly set password

Login successful!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report