Install MySQL5.7 Installation and configuration (YUM) under CentOS7
Installation Environment: CentOS7 64-bit mini version, install MySQL5.7
1. Configure the Yum source
Download the Yum source RPM installation package on the MySQL website: http://dev.mysql.com/downloads/repo/yum/
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9A/71/wKiom1lV66XTlTIJAADSmFJYnuI161.png "title=" 2017-06-30_141030.png "alt=" Wkiom1lv66xtltijaadsmfjynui161.png "/>
# 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
Check that the MySQL source is installed successfully
shell> Yum Repolist enabled | grep "Mysql.*-community.*"
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/9A/72/wKioL1lV67bSbqclAAA6NLXGLl4663.png-wh_500x0-wm_ 3-wmp_4-s_3065236159.png "title=" 2017-06-30_141045.png "alt=" Wkiol1lv67bsbqclaaa6nlxgll4663.png-wh_50 "/>
See shown indicates successful installation
2. Install MySQL
shell> Yum Install Mysql-community-server
3. Start the MySQL service
Shell> systemctl Start mysqld
To view 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 five 2016-06-24 04:37:37 CST; 35min ago Main pid:2888 (mysqld) CGroup:/system.slice/mysqld.service└─2888/usr/sbin/mysqld--daemonize--p Id-file=/var/run/mysqld/mysqld.pid6 month 04:37:36 Localhost.localdomain systemd[1]: Starting MySQL Server ... June 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
4. Boot start
Shell> systemctl enable mysqldshell> Systemctl daemon-reload
5. Change the root default password
After the MySQL installation is complete, a default password is generated for root in the/var/log/mysqld.log file. Locate 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
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9A/72/wKioL1lV7CvADD53AAApIf67rmk789.png "title=" 2017-06-30_141058.png "alt=" Wkiol1lv7cvadd53aaapif67rmk789.png "/>
shell> mysql-uroot-pmysql> ALTER USER ' root ' @ ' localhost ' identified by ' mynewpass4! ';
Or
mysql> set password for ' root ' @ ' localhost ' =password (' mynewpass4! ');
Note: mysql5.7 The password security check plug-in (Validate_password) is installed by default, and the default password check policy requires that the password must contain: uppercase and lowercase letters, numbers, and special symbols, and not less than 8 bits in length. Otherwise you will be prompted for error 1819 (HY000): Your password does not satisfy the current policy requirements error as shown:
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9A/71/wKiom1lV7DjDZ8hyAAAhhdCX_j4911.png "title=" 2017-06-30_141112.png "alt=" Wkiom1lv7djdz8hyaaahhdcx_j4911.png "/>
You can view information about the password policy through the MSYQL environment variable:
Mysql> Show variables like '%password% ';
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9A/71/wKiom1lV7EOjwnm_AABRkXo9NrQ705.png "title=" 2017-06-30_141127.png "alt=" Wkiom1lv7eojwnm_aabrkxo9nrq705.png "/> validate_password_policy: Password policy, default to Medium policy Validate_password_dictionary_file: Password policy file, policy for strong requires validate_password_length: Minimum password length validate_password_mixed_ Case_count: Uppercase and lowercase characters length, at least 1 Validate_password_number_count: numbers at least 1 Validate_password_special_char_count: special characters at least 1 The above parameter is the password check rule for the default policy medium.
There are several password policies:
|
check rules |
0 or Low |
1 or MEDIUM |
2 or STRONG |
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/etc/my.cnf file, specify password policy
# Choose 0 (Low), 1 (MEDIUM), 2 (strong) One of them, select 2 to provide a password dictionary file validate_password_policy=0
If you do not require a password policy, add the following configuration to disable the My.cnf file:
Validate_password = Off
Restarting the MySQL service causes the configuration to take effect:
Systemctl Restart Mysqld
6. Add Telnet user
By default, only the root account is allowed to log on locally, if you want to connect to MySQL on another machine, you must either modify the 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=utf8init_connect= ' Set NAMES UTF8 '
Restart the MySQL service to view the database default encoding as follows:
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/9A/72/wKioL1lV7GfBOYbYAAAnQL_3X9k299.png-wh_500x0-wm_ 3-wmp_4-s_3939140407.png "title=" 2017-06-30_141140.png "alt=" Wkiol1lv7gfboybyaaanql_3x9k299.png-wh_50 "/>
Default profile path: config 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
This article from "Li Shilong" blog, declined reprint!
Install MySQL5.7 Installation and configuration (YUM) under CentOS7