Alibaba Cloud Server Linux system installation database 5.7

Step 1: Install the basic environment before installation: yum install -y perl perl-Module-Build net-tools autoconf libaio numactl-libs 

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

MySQL YUMæºä¸è½½å°å

third step:

Download 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

Step 4: Check whether the mysql source is installed successfully

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

æ£æ¥mysqlæºå®è£æ¯å¦æ£ç¡®

When you see the picture above, the installation is successful. 
You can modify vim /etc/yum.repos.d/mysql-community.repothe source and change the default installed mysql version. For example, to install version 5.6, change the 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:

è¿éåå¾çæè¿°

Step 5: Install mysql

shell> yum install mysql-community-server

Step 6: Start the MySQL service#

shell> systemctl start mysqld

Check the startup status of MySQL

Step 7: Start up

shell> systemctl enable mysqld
shell> systemctl daemon-reload

Step 8: Change the root local login password

After the mysql installation is completed, 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: mysql5.7 has the 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, it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown in the figure below:

å¯ç çç¥æ示

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

mysqlå¯ç ç­ç¥

validate_password_policy: Password policy, the default is MEDIUM policy 
validate_password_dictionary_file: Password policy file, the policy is required to be STRONG 
validate_password_length: Minimum password length 
validate_password_mixed_case_count: Uppercase and lowercase character length, at least 1 
validate_password_number_count: At least 1 number 
validate_password_special_char_count: At least 1 special character 
above parameters It is the password checking rule of the default policy MEDIUM.

There are several password policies:

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

Modify password policy#

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

# Select one of 0 (LOW), 1 (MEDIUM), and 2 (STRONG). Select 2 and you need to provide the 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

Indicate case insensitivity when setting up database queries:

[mysqld]Add a line: lower_case_table_names=1

Restart the mysql service to make the configuration take effect:

systemctl restart mysqld

Step 10: 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 added a new account:

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

Step 11: Configure the default encoding to utf8

Modify the /etc/my.cnf configuration file and add encoding configuration under [mysqld], as shown below

Restart the mysql service and check the database default 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

Guess you like

Origin blog.csdn.net/guoweiting/article/details/105640377