How to change the password of mysql5.7.20 under linux CentOS 7.4

How to change the password of mysql5.7.20 under linux CentOS 7.4

After MySQL was upgraded to version 5.7, its security was greatly improved.

But. . . Can't remember complicated ones. Uh huh. . My brain isn't working well to begin with, so why bother remembering so many complicated things? Especially if it's done locally, it's more convenient to just root.

Enter mysql

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.00
 sec)

According to the official documentation, the strategy is 1, which is MEDIUM

This plugin is installed by default in 5.7. If it is not installed, SHOW VARIABLES LIKE 'vali%' will return empty. The corresponding parameter values ​​are also the default values. The following is an explanation of these values

validate_password_length 8 #
 The minimum password length is 8.
 validate_password_mixed_case_count 1 #
 It must contain at least the number of lowercase or uppercase letters, which is 1 here.
 validate_password_number_count 1 #
 The minimum number of digits to be included, here is 1.
 validate_password_policy MEDIUM #
 Strength level, where its value can be set to 0, 1, 2. Corresponding to:
              【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

1 # The minimum number of characters to be included, here is 1.

So the password you change must contain numbers, lowercase letters, uppercase letters, special characters, and be at least 8 characters long

How to change it? ?

To disable this plugin, add

validate_password=off and restart mysqld:

Add in vim /etc/my.cnf configuration file

[mysqld]
validate_password=off

Then restart mysql and it will be ok.

Restart mysqld

#/etc/init.d/mysqld restart ( service mysqld restart )

If you want to change the password back to enter mysql

The database running 5.7 no longer has a password field and uses the authentication_string field instead.

mysql> update mysql.user set authentication_string=password('root') where user='root';

Finally, you also need to set an expiration time to prevent the password from becoming invalid.

Add in the /etc/my.cnf configuration file

[mysqld]
default_password_lifetime=0

Or directly set it through the command

ALTER USER 'script'@'localhost' PASSWORD EXPIRE NEVER

Summarize

The above is the method for changing the password of mysql5.7.20 under Linux CentOS 7.4 introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to quickly modify the root password under CentOS8
  • CentOS 7 set grub password and single user login example code
  • How to reset the root password in CentOS7
  • How to modify the root password of MySQL in CentOS environment
  • Solution to the problem of still having to enter a password after configuring ssh password-free login in centos
  • How to install and modify the initial password of mysql5.7.18 under Centos7.3
  • How to change mysql password under Centos
  • CentOS 7 Forgot Password Solution Process Diagram

<<:  Sample code for deploying ELK using Docker-compose

>>:  js realizes packaging multiple pictures into zip

Recommend

Detailed explanation of Linux index node inode

1. Introduction to inode To understand inode, we ...

Tomcat class loader implementation method and example code

Tomcat defines multiple ClassLoaders internally s...

Detailed explanation of MySql 5.7.17 free installation configuration tutorial

1. Download the mysql-5.7.17-winx64.zip installat...

Docker deploys net5 program to achieve cross-platform functions

Deployment environment: docker container, liunx s...

JS quickly master ES6 class usage

1. How to construct? Let's review the common ...

A summary of the reasons why Mysql does not use date field index

Table of contents background explore Summarize ba...

Five ways to traverse JavaScript arrays

Table of contents 1. for loop: basic and simple 2...

Docker-compose one-click deployment of gitlab Chinese version method steps

1. Introduction to gitlab Gitlab official address...

Detailed explanation of zabbix executing scripts or instructions on remote hosts

Scenario Requirements 1. We can use the script fu...

Getting Started Tutorial for Beginners ④: How to bind subdirectories

To understand what this means, we must first know ...

What does input type mean and how to limit input

Common methods for limiting input 1. To cancel the...

A brief discussion on the application of Html web page table structured markup

Before talking about the structural markup of web...