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

Configure Java development environment in Ubuntu 20.04 LTS

Download the Java Development Kit jdk The downloa...

A brief discussion on MySQL select optimization solution

Table of contents Examples from real life Slow qu...

Docker configures the storage location of local images and containers

Use the find command to find files larger than a ...

Implementation of Docker CPU Limit

1. --cpu=<value> 1) Specify how much availa...

Solution to nacos not being able to connect to mysql

reason The mysql version that nacos's pom dep...

Detailed explanation of MySQL combined index and leftmost matching principle

Preface I have seen many articles about the leftm...

The perfect solution for Vue routing fallback (vue-route-manager)

Table of contents Routing Manager background gett...

Sample code for implementing multi-application deployment using tomcat+nginx

Table of contents Multi-application deployment 1-...

Encapsulation method of Vue breadcrumbs component

Vue encapsulates the breadcrumb component for you...

How to implement vertical text alignment with CSS (Summary)

The default arrangement of text in HTML is horizo...

Solution for multiple Docker containers not having the same port number

Background In Docker, four containers are created...

CentOS uses expect to remotely execute scripts and commands in batches

Sometimes we may need to operate servers in batch...

A small collection of html Meta tags

<Head>……</head> indicates the file he...

11 Linux KDE applications you didn't know about

KDE Abbreviation for Kool Desktop Environment. A ...

Solve the problem of MySql client exiting in seconds (my.ini not found)

Problem description (environment: windows7, MySql...