This article mainly shares with you the detailed tutorial of installing and configuring MySQL 5.7 under CentOS 7. Mysql5.7 is somewhat different from the previous version of MySQL. Now I will write down the complete process of installing and configuring MySQL 5.7 under CentOS 7, which may be useful for novices. Said it was useful.
Test environment for this article:
CentOS 7 64-bit Minimal MySQL 5.7
Configure yum source
Find the yum source rpm installation package at https://dev.mysql.com/downloads/repo/yum/
rpm installation package
Install mysql source
##
# 下载 shell> wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm # 安装 mysql 源 shell> yum localinstall mysql57-community-release-el7-11.noarch.rpmUse the following command to check whether the mysql source is installed successfully
shell> yum repolist enabled | grep "mysql.*-community.*"
mysql source installation successful
Install MySQL
Use the yum install command to installshell> ; yum install mysql-community-server
shell> systemctl start mysqld
shell> systemctl status mysqld
shell> systemctl enable mysqld shell> systemctl daemon-reload
shell> grep 'temporary password' /var/log/mysqld.log
##View temporary password
After logging in with the initial password for the first time, use the following command to change the password
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; Or
Through update set in the future Statement to change password
Note: mysql 5.7 The password security check plug-in (validate_password) is 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, the error ERROR 1819 (HY000): Your password does not satisfy the current policy requirements will be prompted. View MySQL official website password detailed policy
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 add an account that allows remote connections. Or
Modify root to allow remote connections(not recommended)Add an account that allows remote connections
mysql> GRANT ALL PRIVILEGES ON *.* TO 'zhangsan'@'%' IDENTIFIED BY 'Zhangsan2018!' WITH GRANT OPTION;
(not recommended)
mysql> use mysql; mysql> UPDATE user SET Host='%' WHERE User='root'; mysql> flush privileges;Set the default encoding to utf8
mysql does not support Chinese by default after installation, and the encoding needs to be modified.
Modify the /etc/my.cnf configuration file and add the encoding configuration under the relevant node (if not, add it yourself), as follows:The code is as follows:
[mysqld]character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
Restart the mysql service and query the encoding. You can see that it has been changed
Configuration file:/etc/my.cnf
Log file:/var/log/var/log/mysqld.logService startup script:/usr/ lib/systemd/system/mysqld.service
socket file:/var/run/mysqld/mysqld.pid
Related recommendations:
Graphical tutorial on installation and configuration method of mysql 5.7.18 under CentOS 7
The above is the detailed content of Detailed tutorial on installing and configuring MySQL 5.7 under CentOS 7. For more information, please follow other related articles on the PHP Chinese website!