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

How does mysql reset the root password

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "mysql how to reset root password", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "mysql how to reset root password"!

Forgetting the root password is fatal for databases, but we can skip the permissions table by adding the--ship-grant-tables parameter.

The specific methods are as follows:

Forgot root password, unable to access database:

At this time, you need to force the database to stop, first check the MySQL process number

Kill MySQL process with the following command:

After Kill, you can check to see if there is any progress.

[root@tse2 tmp]# kill -9 9840 1[root@tse2 tmp]# ps -ef |grep mysql

It is recommended to stop this operation without affecting the business, stop the service operation, and it is best to record this password well, you can use keepass to save password software!

Free learning video tutorial Share: mysql video tutorial

Then add the Skip Permission Table parameter and restart the database. This allows access to the database without entering a password.

[root@tse2 bin]# mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &[1] 4854

You can enter mysql directly without password.

Set a new password for root and refresh permissions. After MySQL 5.7, the password field under the library is replaced with the authentication_string field.

(product)root@localhost:mysql.sock [(none)]> use mysql;Database changed(product)root@localhost:mysql.sock [mysql]> update user set authentication_string=password('123456') where user='root';Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 1(product)root@localhost:mysql.sock [mysql]> flush privileges;Query OK, 0 rows affected (0.00 sec)

After the setup is complete, restart the database. Note that you do not need to add the--skip-grant-tables parameter when restarting. You can start the service normally and enter the new password to enter the database normally. Here after the restart test directly mysql no password is unable to enter the.

[root@tse2 bin]# mysqld_safe --deaults-file=/etc/my.cnf &[2] 6720[root@tse2 bin]# 2020-01-16T02:55:45.223195Z mysqld_safe Logging to '/mysql/mysql3306/logs/error.log'.2020-01-16T02:55:45.262302Z mysqld_safe A mysqld process already exists[2]+ Exit 1 mysqld_safe --deaults-file=/etc/my.cnf[root@tse2 bin]# mysqlERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Enter the password here to connect, you can enter normally, it is the modified password 123456

[root@tse2 bin]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.23-log MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. (product)root@localhost:mysql.sock [(none)]> use mysqlDatabase changed(product)root@localhost:mysql.sock [mysql]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+---------------------+rows in set (0.01 sec) At this point, I believe that everyone has a deeper understanding of "mysql how to reset the root password," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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

Development

Wechat

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

12
Report