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

Complete steps for mysql8 to reset root user password

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

Share

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

Preface

Recently, many new colleagues have asked this question, especially through the automatic installation of mysql through homebrew, the default version is 8.0. due to the addition of some security policies and other restrictions, it will be a little more troublesome to change the user's password, so just post this summary.

I won't say much. Let's take a look at the detailed introduction.

The steps are as follows:

1. First, check the relevant information about root users, in the user table of mysql database:

Select host, user, authentication_string, plugin from user

Host: the ip' location'% where the user is allowed to log in indicates that it can be remotely

User: the user name of the current database

Authentication_string: user password; discarded the password field and password () function after mysql 5.7.9

Plugin: password encryption method

If you find something under the authentication_string field of the root user, set it to empty first:

Use mysql;update user set authentication_string='' where user='root'

2. Restart the mysql service and directly order the mac to shut down the service:

Mysql.server stop

Or kill the mysql process. Then start the mysql service:

Mysql.server start

3. Log in with root users. Because authentication_string has been set to empty, you can log in without a password:

Mysql-u root-ppasswrod:

You don't need to enter the password, you can enter directly.

4. Enter the mysql library and use ALTER to modify the root user password:

ALTER user 'root' IDENTIFIED BY' 123456'

The root in the statement depends on whether the root users in your actual user table store root or root@localhost. Since I have changed the password here to a relatively simple format such as 123456, the default password policy of mysql 8 may not allow it. If you have to change it, you can change the password policy first:

Set global validate_password.length = 6; set global validate_password.policy = 'LOW';FLUSH PRIVILEGES

Here, the password length is changed from the default 8 digits to 6 digits, and the password policy level is changed from MEDIUM to LOW. If you want to view the settings related to password verification, you can query the system variable directly:

SHOW VARIABLES LIKE 'validate_password.%'

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

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