CentOS7 data server set up

Installation MySQL8

CentOS7 default database is MySQL and MariaDB does not exist yum source, so the first step is to download the source MySQL

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

9261086-1ba172df1636d82b.png

I found no wget command to install wget

yum -y install wget

9261086-8d421d1c9d0cb6aa.png

After a successful download in the root directory of the source

yum localinstall mysql80-community-release-el7-1.noarch.rpm

Installation Source

yum clean all
yum makecache

The source into force

yum install mysql-community-server

Install mysql, this process is relatively long

Change password

9261086-609d80301150c9ee.png

After a successful installation can not log on at reboot

9261086-f9cd2f862f0a3b32.png

You must enter a password

cat /var/log/mysqld.log | grep password

View the default password

9261086-3edc85033076d6d6.png

mysql -u root -p

After logging Changing the root password

alter user root@localhost identified by 'Root_123456';

Passwords must include the case of digital special characters

flush privileges;

Refresh

9261086-5e1ddf6d9e26b09a.png

exit

sign out

Create a user

External connections can not use the root user, the user needs to open separate and assign different privileges to use external

create user mysqluser@'%' identified by 'MySQL_user123';

Creating mysqluser user to specify the source address of its access% of all

grant permissions on database table names to user login name @ host

grant all privileges on *.* to mysqluser@'%' with grant option;

. : The first represents the database name; the second represents the name of the table (refer to all database tables are granted to all users, if only authorize a database or database at a particular table, put * replace the database and table to )

flush privileges;

Firewall

In this case the external connections failed data server

9261086-13ce907916bf80a3.png

Because the firewall firewall Centos7 not open port 3306

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

--zone # scope
--add-port = 3306 / tcp # Add port, the format is: port / protocol
--permanent # permanent, this parameter does not restart after failure

systemctl restart firewalld.service

Restart the firewall

9261086-f3e8746db76f8431.png
9261086-fee29e4e9a74fcdb.png

External connection is successful

Guess you like

Origin blog.csdn.net/weixin_34077371/article/details/90912771