CentOS7 MySQL5.7 mounted installation and configuration (YUM)
http://blog.csdn.net/xyang81/article/details/51759200
Installation Environment: CentOS7 64 Wei MINI version, installation MySQL5.7
1, a source configured YUM
In MySQL download the source rpm YUM installation package official website: http://dev.mysql.com/downloads/repo/yum/
# 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm # 安装mysql源 shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
Check whether the installation was successful mysql source
shell> yum repolist enabled | grep "mysql.*-community.*"
See represents the successful installation shown in FIG.
2, Installing MySQL
shell> yum install mysql-community-server
3, start the MySQL service
shell> systemctl start mysqld
View start-up state 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; 35min ago Main PID: 2888 (mysqld) CGroup: /system.slice/mysqld.service └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server... 6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
4, boot
shell> systemctl enable mysqld
shell> systemctl daemon-reload
5, modify the default root password
Mysql After installation is complete, /var/log/mysqld.log file to generate a default root password. Find the root password by default in the following manner, and then log mysql modify:
shell> grep 'temporary password' /var/log/mysqld.log
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
or
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
Note: mysql5.7 default installation password security check-ins (validate_password), check the default password policy requires password must contain: uppercase and lowercase letters, numbers and special symbols, and the length can not be less than eight. Otherwise it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown below:
You can view information about password policies through msyql environment variables:
mysql> show variables like '%password%';
validate_password_policy: password policy, the default is MEDIUM strategy validate_password_dictionary_file: password policy file, the policy is only required STRONG validate_password_length: Minimum password length validate_password_mixed_case_count: uppercase and lowercase characters length, at least one validate_password_number_count: Digital least one validate_password_special_char_count: at least one special character above parameters is the default strategy MEDIUM password checking rules.
There are several password policy:
Tactics | 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 |
MySQL network password policy official details: 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 /etc/my.cnf configuration file, specify a password policy
# 选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件
validate_password_policy=0
If no password policy, add the my.cnf file, add the following configuration can be disabled:
validate_password = off
Restart the mysql service to validate the configuration:
systemctl restart mysqld
6, add a remote user login
By default only allow the root account to log on locally, if you want to connect mysql on another machine, you must modify the root allow remote connections, or add an account to allow remote connections, for security reasons, I add a new account:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;
7, configured default encoding is utf8
/Etc/my.cnf modify the configuration file, add code disposed [mysqld] next, as follows:
[mysqld]
character_set_server=utf8 init_connect='SET NAMES utf8'
Restart the mysql service, view the database default encoding is as follows:
The default configuration file path: Profile: /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
http://blog.csdn.net/xyang81/article/details/51759200
Installation Environment: CentOS7 64 Wei MINI version, installation MySQL5.7
1, a source configured YUM
In MySQL download the source rpm YUM installation package official website: http://dev.mysql.com/downloads/repo/yum/
# 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm # 安装mysql源 shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
Check whether the installation was successful mysql source
shell> yum repolist enabled | grep "mysql.*-community.*"
See represents the successful installation shown in FIG.
2, Installing MySQL
shell> yum install mysql-community-server
3, start the MySQL service
shell> systemctl start mysqld
View start-up state 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; 35min ago Main PID: 2888 (mysqld) CGroup: /system.slice/mysqld.service └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server... 6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
4, boot
shell> systemctl enable mysqld
shell> systemctl daemon-reload
5, modify the default root password
Mysql After installation is complete, /var/log/mysqld.log file to generate a default root password. Find the root password by default in the following manner, and then log mysql modify:
shell> grep 'temporary password' /var/log/mysqld.log
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
or
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
Note: mysql5.7 default installation password security check-ins (validate_password), check the default password policy requires password must contain: uppercase and lowercase letters, numbers and special symbols, and the length can not be less than eight. Otherwise it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown below:
You can view information about password policies through msyql environment variables:
mysql> show variables like '%password%';
validate_password_policy: password policy, the default is MEDIUM strategy validate_password_dictionary_file: password policy file, the policy is only required STRONG validate_password_length: Minimum password length validate_password_mixed_case_count: uppercase and lowercase characters length, at least one validate_password_number_count: Digital least one validate_password_special_char_count: at least one special character above parameters is the default strategy MEDIUM password checking rules.
There are several password policy:
Tactics | 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 |
MySQL network password policy official details: 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 /etc/my.cnf configuration file, specify a password policy
# 选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件
validate_password_policy=0
If no password policy, add the my.cnf file, add the following configuration can be disabled:
validate_password = off
Restart the mysql service to validate the configuration:
systemctl restart mysqld
6, add a remote user login
By default only allow the root account to log on locally, if you want to connect mysql on another machine, you must modify the root allow remote connections, or add an account to allow remote connections, for security reasons, I add a new account:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;
7, configured default encoding is utf8
/Etc/my.cnf modify the configuration file, add code disposed [mysqld] next, as follows:
[mysqld]
character_set_server=utf8 init_connect='SET NAMES utf8'
Restart the mysql service, view the database default encoding is as follows:
The default configuration file path: Profile: /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