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

JavaScript implements countdown on front-end web page

Use native JavaScript to simply implement the cou...

Teach you step by step to configure MySQL remote access

Preface When using the MySQL database, sometimes ...

Detailed explanation of the difference between uniapp and vue

Table of contents 1. Simple page example 2.uni-ap...

How to convert rows to columns in MySQL

MySQL row to column operation The so-called row-t...

Detailed explanation of CSS line-height and height

Recently, when I was working on CSS interfaces, I...

MySQL 5.7.17 installation and configuration tutorial for Mac

1. Download MySQL Click on the official website d...

JavaScript implements select all and unselect all operations

This article shares the specific code for JavaScr...

Detailed summary of MySQL and connection-related timeouts

MySQL and connection related timeouts Preface: To...

The process of SSH service based on key authentication in Linux system

As we all know, SSH is currently the most reliabl...

Detailed explanation of Linux DMA interface knowledge points

1. Two types of DMA mapping 1.1. Consistent DMA m...

How to cancel the background color of the a tag when it is clicked in H5

1. Cancel the blue color of the a tag when it is ...

Detailed explanation of redundant and duplicate indexes in MySQL

MySQL allows you to create multiple indexes on th...

A brief analysis of MySQL parallel replication

01 The concept of parallel replication In the mas...

How to write the introduction content of the About page of the website

All websites, whether official, e-commerce, socia...