MySQL 5.7 installation and configuration tutorial under CentOS7 (YUM)

MySQL 5.7 installation and configuration tutorial under CentOS7 (YUM)

MySQL official website password policy detailed description: http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy

Modify Password Policy

Add validate_password_policy configuration in the /etc/my.cnf file to specify the password policy

# Select one of 0 (LOW), 1 (MEDIUM), 2 (STRONG). Selecting 2 requires providing a password dictionary file validate_password_policy=0

If you do not need a password policy, add the following configuration to the my.cnf file to disable it:

validate_password = off

Restart the MySQL service to make the configuration take effect:

systemctl restart mysqld

6. Add remote login user

By default, only the root account is allowed to log in locally. If you want to connect to MySQL on other machines, you must modify root to allow remote connections, or add an account that allows remote connections. For security reasons, I add a new account:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;

7. Configure the default encoding to utf8

Modify the /etc/my.cnf configuration file and add the encoding configuration under [mysqld] as follows:

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

Restart the mysql service and check the default database encoding as follows:

mysql默認編碼

Default configuration file path:

Configuration file: /etc/my.cnf
Log file: /var/log//var/log/mysqld.log
Service startup script: /usr/lib/systemd/system/mysqld.service
Socket file: /var/run/mysqld/mysqld.pid

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:
  • Tutorial on installing lnmp using yum on centos7 (linux+nginx+php7.1+mysql5.7)
  • Detailed steps to install Mysql5.7.19 using yum on Centos7
  • How to quickly install MySQL 5.7 using YUM under Centos 7.2
  • Detailed steps to install MySQL 5.7 via YUM on CentOS7

Installation environment: CentOS7 64-bit, MySQL5.7

1. Configure YUM source

Download the YUM source rpm installation package from the MySQL official website: http://dev.mysql.com/downloads/repo/yum/

MySQL YUM源下載地址

# Download the mysql source installation package shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# Install mysql source shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm

Check whether the mysql source is installed successfully

shell> yum repolist enabled | grep "mysql.*-community.*"

檢查mysql源安裝是否正確
The above picture shows that the installation is successful.
You can modify the vim /etc/yum.repos.d/mysql-community.repo source to change the default installed MySQL version. For example, to install version 5.6, change enabled=1 of the 5.7 source to enabled=0. Then change the enabled=0 of the 5.6 source to enabled=1. The effect after the modification is as follows:

2. Install MySQL

shell> yum install mysql-community-server

3. Start MySQL service

shell> systemctl start mysqld

Check the startup status of MySQL

shell> systemctl status mysqld
● mysqld.service – MySQL Server
 Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
 Active: active (running) since 2016-06-24 04:37:37 CST; 35 minutes ago
 Main PID: 2888 (mysqld)
 CGroup: /system.slice/mysqld.service
   └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Jun 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...
Jun 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.

4. Start the machine

shell> systemctl enable mysqld
shell> systemctl daemon-reload

5. Modify the root local login password

After mysql is installed, a default password is generated for root in the /var/log/mysqld.log file. Find the root default password in the following way, and then log in to mysql to modify it:

shell> grep 'temporary password' /var/log/mysqld.log

root默認密碼

shell>mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 

or

mysql> set password for 'root'@'localhost'=password('MyNewPass4!'); 

Note: MySQL 5.7 has a password security check plug-in (validate_password) installed by default. The default password check policy requires that the password must contain uppercase and lowercase letters, numbers, and special symbols, and the length must not be less than 8 characters. Otherwise, the error message ERROR 1819 (HY000): Your password does not satisfy the current policy requirements will be displayed, as shown in the following figure:
密碼策略提示

You can view password policy information through the msyql environment variable:

mysql> show variables like '%password%'; 

mysql密碼策略

validate_password_policy: Password policy, the default is MEDIUM policy
validate_password_dictionary_file: Password policy file, required only if the policy is STRONG
validate_password_length: minimum password length
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
The above parameters are the password checking rules for the default policy MEDIUM.

There are the following password policies:

<<:  A method of hiding processes under Linux and the pitfalls encountered

>>:  Secondary encapsulation of element el-table table (with table height adaptation)

Recommend

Tutorial on using $attrs and $listeners in Vue

Table of contents introduce Example Summarize int...

CSS scroll-snap scroll event stop and element position detection implementation

1. Scroll Snap is a must-have skill for front-end...

Implementation example of react project from new creation to deployment

Start a new project This article mainly records t...

Detailed explanation of CSS3 Flex elastic layout example code

1. Basic Concepts //Any container can be specifie...

MySql Sql optimization tips sharing

One day I found that the execution speed of a SQL...

MySQL Best Practices: Basic Types of Partition Tables

Overview of MySQL Partitioned Tables As MySQL bec...

innerHTML Application

Blank's blog: http://www.planabc.net/ The use...

CSS3 overflow property explained

1. Overflow Overflow is overflow (container). Whe...

The use of FrameLayout in six layouts

Preface In the last issue, we explained LinearLay...

JavaScript flow control (loop)

Table of contents 1. for loop 2. Double for loop ...

Detailed explanation of asynchronous programming knowledge points in nodejs

Introduction Because JavaScript is single-threade...

Summary of JavaScript's setTimeout() usage

Table of contents 1. Introduction 2. The differen...

Detailed explanation of the difference between alt and title

These two attributes are often used, but their di...