Download MySQL installation
[root@localhost ~]# cd /home/data/ [root@localhost data]# ls get-docker.sh nginx-1.10.1 nginx-1.10.1.tar.gz redis-5.0.3 redis-5.0.3.tar.gz server-jre-8u131-linux-x64.tar.gz zookeeper-3.4.10.tar.gz [root@localhost data]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
If prompted that the wget command does not exist, execute it first
yum -y install wget
When the download is complete, there is one more file named mysql57-xxx, which is the source of MySQL installation
Install mysql installation source
[root@localhost data]# yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
Install MySQL Online
[root@localhost data]# yum -y install mysql-community-server
Start MySQL Service
[root@localhost data]# systemctl start mysqld
Set up boot-up
[root@localhost data]# systemctl enable mysqld [root@localhost data]# systemctl daemon-reload
Modify root login password
When mysql is installed, a temporary default password is generated for root in the / var/log/mysqld.log file.
[root@localhost data]# vim /var/log/mysqld.log
Copy this password and use it to log in to root
[root@localhost data]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.25 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
To change the password, the mysql5.7 default password policy requires that the password must be a combination of special letters in uppercase and lowercase letters, with at least 8 bits. You can modify the policy
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test2016@'; Query OK, 0 rows affected (0.01 sec)
If Your password does not satisfy the current policy requirements indicates that the password you are currently setting does not conform to the current policy, the following configuration is required
1,See mysql Initial password policy mysql> SHOW VARIABLES LIKE 'validate_password%'; 2,Set password authentication strength level mysql> set global validate_password_policy=LOW; 3,Set the password length, note:Minimum password length is 4, if less than 4, then default is 4 mysql> set global validate_password_length=6;
Set to allow remote login
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Test2016@' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.00 sec)
The firewall opens port 3306 because my firewall is off, so I don't need to do this step
[root@localhost data]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost data]# firewall-cmd --reload success [root@localhost data]#
Configure mysql with utf-8 as the default encoding in/etc/my.cnf
vi /etc/my.cnf character_set_server=utf8 init_connect='SET NAMES utf8'
Restart MySQL
[root@localhost data]# systemctl restart mysqld
Log on to root user to view encoding
mysql> show variables like '%123456%';
Test remote connection