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

Reset the password of the root user in the MySQL database

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

Share

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

The method to change the password when the ROOT user password of the MYSQL database is known:

1. In SHELL environment, use the mysqladmin command to set: mysqladmin-u root-p password enter the old password after entering the "new password"

2. In the mysql > environment, use the update command to directly update the data of the user table of the mysql library:

Update mysql.user set password=password ('new password') where user='root'

Flush privileges

Note: the mysql statement ends with a semicolon ";"

3. In the mysql > environment, use the grant command to modify the authorization permissions of the root user.

Grant all on *. * to root@'localhost' identified by 'new password'

What if I forget the password of the ROOT user in the mysql database? The methods are as follows:

1. Close the currently running mysqld service program: service mysqld stop (to add mysqld as a system service first)

2. Use the mysqld_safe script to start the mysqld service in safe mode (without loading the authorization table)

/ usr/local/mysql/bin/mysqld_safe-skip-grant-table &

3. Log in to the database with a root user with an empty password and reset the password of the ROOT user

# mysql-u root

Mysql > Update mysql.user set password=password ('new password') where user='root'

Mysql > flush privileges

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