One-click installation of MySQL 5.7 and password policy modification method

One-click installation of MySQL 5.7 and password policy modification method

1. One-click installation of Mysql script

[root@uat01 ~]# cat InstallMysql01.sh 
#!/bin/bash
#2018-10-13
#Travel
#1. Install wget
yum -y install wget
#2. Download the yum source URL of mysql="https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm"
wget $URL -P /etc/yum.repos.d/
yum -y install yum-utils #If the package is not available, the following yum-config-manager command will not work yum -y install /etc/yum.repos.d/mysql80-community-release-el7-1.noarch.rpm
 if [ $? -eq 0 ];then
  rm -rf /etc/yum.repos.d/mysql80-community-release-el7-1.noarch*
 fi
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
yum -y install mysql-community-server
 sleep 5
 systemctl start mysqld 
 systemctl enable mysqld
 systemctl status mysqld
 if [ $? -eq 0 ];then
  echo -e "install succefull"
  result="`grep 'temporary password' /var/log/mysqld.log`"
  p1="`echo $result |awk '{print $NF}'`"
  echo "The database password is: $p1"
 
 fi
[root@uat01 ~]#

2. Modify policies and passwords

After executing the above script, you can see the password of Mysql. You can log in and modify the policy as follows. Because the default password requirement is relatively high, you can decide whether to change the policy according to your needs:

install successfully
The database password is: 9aTR1K
[root@uat01 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'root'@'localhost' identified by 'Yanglt123.';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

3. Database password strategy:

1. View the database policy:

Because the validate_password_length value has been changed to 4 above, it is displayed as 4 below. The default value is 8

[root@uat01 ~]# mysql -uroot -p
.....
Server version: 5.7.23 MySQL Community 
......
mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 4 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

mysql>

2. Description of each value

validate_password_policy: Password security policy, default MEDIUM policy

Strategy Check the rules
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

validate_password_dictionary_file: Password policy file, required only if the policy is STRONG

validate_password_length: minimum password length. Testing found that the minimum value is 4.

validate_password_mixed_case_count: length of uppercase and lowercase characters, at least 1

validate_password_number_count: at least 1 number

validate_password_special_char_count: at least 1 special character

3. Modify the strategy, the same as the second operation above

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec),
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4. Modify the simple password test

mysql> alter user 'root'@'localhost' identified by '1234'; #Test found that the password length is at least 4 characters Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@uat01 ~]# mysql -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.23 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 its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

Summarize

The above is the one-click installation of MySQL 5.7 and the password policy modification method 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!

You may also be interested in:
  • Tutorial on installing and changing the root password of MySQL 5.7.20 decompressed version
  • MySQL 5.7.21 installation and password configuration tutorial
  • MySQL 5.7.19 installation tutorial under Windows 10 How to change the root password of MySQL after forgetting it
  • How to install and modify the initial password of mysql5.7.18 under Centos7.3
  • How to install and modify the initial password of mysql5.7.18
  • Mysql5.7.14 installation and configuration method operation graphic tutorial (password problem solution)
  • MySQL 5.7 installation process and method to reset the root password (shell script)

<<:  How to view and close background running programs in Linux

>>:  Information transmission and function calls between WeChat mini program pages and components

Recommend

Summary of how to add root permissions to users in Linux

1. Add a user . First, use the adduser command to...

Detailed explanation of MySQL 8.0.18 commands

Open the folder C:\web\mysql-8.0.11 that you just...

CSS3 achieves cool sliced ​​image carousel effect

Today we will learn how to use CSS to create a co...

Summary of several replication methods for MySQL master-slave replication

Asynchronous replication MySQL replication is asy...

Join operation in Mysql

Types of joins 1. Inner join: The fields in the t...

WeChat applet implements waterfall flow paging scrolling loading

This article shares the specific code for WeChat ...

WeChat applet learning notes: page configuration and routing

I have been studying and reviewing the developmen...

Solution to MySql Error 1698 (28000)

1. Problem description: MysqlERROR1698 (28000) so...

Detailed explanation of Mysql self-join query example

This article describes the Mysql self-join query....