Install and configure MySQL5.7 in 64-bit CentOS7

Source: Internet
Author: User
Tags yum repolist

Install and configure MySQL5.7 in 64-bit CentOS7

Installation environment: CentOS7 64-bit MINI version, install MySQL5.7

1. Configure the YUM Source

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

Download the mysql source installation package

None> wgethttp: // dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

Install mysql Source

None> 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.
You can modify the vim/etc/yum. repos. d/mysql-community.repo source 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

None> yum install mysql-community-server

3. Start the MySQL Service

None> systemctl start mysqld

View the MySQL startup status

None> systemctl status mysqld

● Mysqld. service-MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld. service; disabled; vendor preset: disabled)

Active: active (running) since 5 2016-06-24 04:37:37 CST; 35 min ago

Main PID: 2888 (mysqld)

CGroup:/system. slice/mysqld. service

       └─2888/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

June 24 04:37:36 localhost. localdomain1_emd [1]: Starting MySQL Server...

June 24 04:37:37 localhost. localdomain1_emd [1]: Started MySQL Server.

4. boot

None> systemctl enable mysqld

None> 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:

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

None> mysql-uroot-p

Mysql> alter user 'root' @ 'localhost' identified by 'mynewpass4! ';

Or

Mysql> set password for 'root' @ 'localhost' = password ('mynewpass4! ');

Note: The password security check plug-in (validate_password) is installed in mysql5.7 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 thecurrent policy requirements is displayed,

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

Validate_password_policy: Password Policy. The default value is the MEDIUM policy validate_password_dictionary_file: password policy file. If the policy is STRONG, validate_password_length is required. The minimum password length is uppercase/lowercase, and at least one validate_password: the number must have at least one validate_password_special_char_count: the special character must have at least one. The preceding parameter is the password check rule of the Default policy MEDIUM.

There are several password policies:

Policy

Check 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 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:

Systemctlrestart 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 'yangxin0917! 'Withgrant 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 = utf8

Init_connect = 'setnames 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

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.