How to change the root password in MySQL 5.7

How to change the root password in MySQL 5.7

Starting from MySQL 5.7, many security updates have been added. Users of older versions may not be used to it. Here we introduce the database password issue for version 5.7.

Versions 5.7.6 and later

Versions 5.7.6 and later will generate a password and put it in the log file when starting the database, like this:

[root@centos-linux ~]# cat /var/log/mysqld.log | grep 'password'
2016-07-16T03:07:53.587995Z 1 [Note] A temporary password is generated for root@localhost: 2=s6NZk.t:fz

Then use the password to log in to the database, but you cannot perform any operations and will be prompted to change the password first.

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

When you modify the password here, you will encounter verification. Simple passwords will prompt that they do not comply with the rules.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Because 5.7 introduced a validate_password plugin to check the password strength.

The default values ​​are as follows:

mysql> show variables like 'vali%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file | | 
| validate_password_length | 8 | 
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
6 rows in set (0.01 sec)

The meaning is as follows:

validate_password_length
# The minimum length of the password, default is 8.
validate_password_mixed_case_count
# The minimum number of lowercase or uppercase letters required. The default is 1.
validate_password_number_count
# The minimum number of digits to be included. The default is 1.
validate_password_policy 
# Strength level, can be set to 0, 1, 2.
  【0/LOW】: Only check the length.
  [1/MEDIUM]: Checks numbers, uppercase and lowercase letters, and special characters based on level 0.
  [2/STRONG]: Check the special character dictionary file based on level 1. Here, it is 1.
validate_password_special_char_count
# The minimum number of special characters to be included. The default is 1.

Therefore, the initial password should be greater than 8 characters and contain numbers, uppercase and lowercase letters, and special characters.

You can also modify the above configurations to weaken password strength verification.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to modify the root user password in mysql 8.0.16 winx64 and Linux
  • How to correctly modify the ROOT password in MySql8.0 and above versions
  • MySQL 5.6 root password modification tutorial
  • Tutorial on how to modify the root password in MySQL 5.7
  • Summary of how to modify the root password in MySQL 5.7 and MySQL 8.0
  • Detailed explanation of the idea of ​​installing mysql8.0.11 and changing the root password and connecting navicat for mysql
  • Multiple methods to modify MySQL root password (recommended)
  • Mysql forget the root password and change the root password solution (summary)
  • How to change the root user's password in MySQL

<<:  How to use jconsole to monitor remote Tomcat services

>>:  Detailed explanation of Vue's self-implementation of dispatch and broadcast (dispatch and broadcast)

Recommend

Vue uses OSS to upload pictures or attachments

Use OSS to upload pictures or attachments in vue ...

A brief discussion on tags in HTML

0. What is a tag? XML/HTML CodeCopy content to cl...

Detailed explanation of MySQL cursor concepts and usage

This article uses examples to explain the concept...

How to use nginx as a load balancer for mysql

Note: The nginx version must be 1.9 or above. Whe...

Several ways to switch between Vue Tab and cache pages

Table of contents 1. How to switch 2. Dynamically...

Analysis of the process of implementing Nginx+Tomcat cluster under Windwos

Introduction: Nginx (pronounced the same as engin...

How to get USB scanner data using js

This article shares the specific process of js ob...

Vue imitates ElementUI's form example code

Implementation requirements The form imitating El...

CSS beginner tutorial: background image fills the entire screen

If you want the entire interface to have a backgr...

Solutions to Mysql index performance optimization problems

The optimization created by MySQL is to add index...

CSS3 border effects

What is CSS# CSS (abbreviation of Cascading Style...

Summary of Vue's common APIs and advanced APIs

Table of contents nextTick Mixins $forceUpdate se...