Download the mysql installation package

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Copy the code

2. Install the mysql source

 yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
Copy the code

3. Install mysql Server

yum -y install mysql-community-server
Copy the code

4. Start mysql

systemctl start mysqld
Copy the code

5. Set boot

systemctl enable mysqld

systemctl daemon-reload
Copy the code

6. View the default password

 cat /var/log/mysqld.log | grep password
Copy the code

7. Change the database password

Mysql -uroot -p

Enter the command to modify

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'hsywhy1212.'; The exit exitCopy the code

8. Set remote access permissions

Log in to the database mysql -uroot -p

Create a remote root user using encryption

Create user 'root'@'%' identified with mysql_native_password by 'your password ';Copy the code

Grant permission to Execute

grant all privileges on *.* to 'root'@'%' with grant option;
Copy the code

Refresh the permissions

flush privileges;
Copy the code

Out of the exit

9. Enable firewall port 3306

systemctl start firewalld
Copy the code

Open port 3306

firewall-cmd --zone=public --add-port=3306/tcp --permanent
Copy the code

Firewall reload configuration execution

firewall-cmd --reload
Copy the code

Don’t forget to configure port 3306 in the server security group as well

10. Configure the UTF-8 database

Add the following encoding configuration to the /etc/my.cnf file

character_set_server=utf8
init_connect='SET NAMES utf8'
Copy the code

cd /etc 

vim my.cnf

I is to edit esc: wq and exit

11. Restart mysql

systemctl restart mysqld
Copy the code