How to install and configure MySQL5.7 in CentOS7: graphic tutorial (YUM) and centos7mysql5.7

Source: Internet
Author: User
Tags yum repolist

How to install and configure MySQL5.7 in CentOS7: graphic tutorial (YUM) and centos7mysql5.7

Installation environment: CentOS7 64-bit, MySQL5.7

1. Configure the YUM Source

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

# 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 whether the mysql source is successfully installed.

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


The installation is successful.
Modifiablevim /etc/yum.repos.d/mysql-community.repoSource to change the mysql version installed by default. For example, to install version 5.6, change enabled = 1 of the 5.7 source to enabled = 0. Then, change enabled = 0 of 5.6 source to enabled = 1. The effect after the change is as follows:

2. Install MySQL

shell> yum install mysql-community-server

3. Start the MySQL Service

shell> systemctl start mysqld

View the MySQL startup status

Shell> systemctl status mysqld ● mysqld. service-MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld. service; disabled; vendor preset: disabled) Active: active (running) since 5 04:37:37 CST; 35 min ago Main PID: 2888 (mysqld) CGroup:/system. slice/mysqld. service expose-2888/usr/sbin/mysqld -- daemonize -- pid-file =/var/run/mysqld. pid June 24 04:37:36 localhost. localdomain systemd [1]: Starting MySQL Server... june 24 04:37:37 localhost. localdomain systemd [1]: Started MySQL Server.

4. boot

shell> systemctl enable mysqldshell> 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 default root password in the following way, and then log on to mysql to modify it:

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

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

Or

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

Note:Mysql5.7 is installed with the password security check plug-in (validate_password) by default. The default password check policy requires that the password must contain uppercase and lowercase letters, numbers, and special characters, and the length cannot be less than 8 characters. Otherwise, ERROR 1819 (HY000): Your password does not satisfy the current policy requirements is returned, as shown in:

You can use the msyql environment variable to view information about the password policy:

mysql> show variables like '%password%';

 

Validate_password_policy: Password Policy. The default value is MEDIUM.
Validate_password_dictionary_file: password policy file, which is required only when the password policy is STRONG.
Validate_password_length: Minimum Password Length
Validate_password_mixed_case_count: case-sensitive length, at least 1
Validate_password_number_count: at least one number
Validate_password_special_char_count: at least one special character
The above parameters are the password check rules of the Default policy MEDIUM.

There are several password policies:

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

Change Password Policy

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

# Select either 0 (LOW), 1 (MEDIUM), or 2 (STRONG). Select 2 and 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

Restart the mysql service to make the configuration take effect:

systemctl restart mysqld

6. Add a remote logon user

By default, only the root account is allowed to log on locally. To connect to mysql on other machines, you must modify the root account to allow remote connection or add an account that allows remote connection. For security reasons, add a new account:

Mysql> grant all privileges on *. * TO 'angxin' @ '%' identified by 'angxin0917! 'With grant option;

7. Set the default encoding to utf8.

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

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

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

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. pid

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.