Centos7 mysql installation

MariaDB is installed in CentOS by default. MariaDB is a branch of MySQL, but it is necessary to install MySQL on the system. MariaDB can be overwritten after installing MySQL.

1 Download and install the official MySQL Yum Repository

[root @ localhost ~] dev.mysql.com/get/mysql57 # wget – I – c…

Yum Repository: Yum Repository: Yum Repository: Yum Repository: Yum Repository: Yum Repository: Yum Repository

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm

Then start installing MySQL server.

[root@localhost ~]# yum -y install mysql-community-server this step may take some time and will overwrite the previous mariadb when the installation is complete.

Now that MySQL is installed, there are some Settings for MySQL.

2 MySQL database Settings

[root@localhost ~]# systemctl start mysqld.service [root@localhost ~]# systemctl status mysqld.service

If you want to access MySQL, you need to find the password of user root. Run the following command to find the password in the log file:

[root@localhost ~]# grep “password” /var/log/mysqld.log

Run the following command to enter the database:

[root@localhost ~]# mysql -uroot -p

Enter the initial password (no at the end of the image above; e! 5>>alfg), cannot do anything at this time, because MySQL must change the password by default to operate the database:

mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘new password’;

Where ‘new password’ is replaced with the password you want to set, note: password Settings must be upper case alphanumeric and special characters (,/’; : etc.), or the configuration fails

3 Enable remote access to the mysql database

Run the following command to enable remote access restriction (note: the following command enables the IP address 192.168.0.1, to enable all, use % instead of IP) :

Grant all PRIVILEGES on. To ‘root’@’192.168.0.1’ IDENTIFIED by ‘password’ with grant option;

Then enter the following two commands

mysql> flush privileges; mysql> exit

4 Add open ports to Firewalld

Add mysql port 3306 and Tomcat port 8080

[root@localhost ~]# firewall-cmd –zone=public –add-port=3306/tcp –permanent [root@localhost ~]# firewall-cmd –zone=public –add-port=8080/tcp –permanent

And then reload

[root@localhost ~]# firewall-cmd –reload

5 Change the mysql language

First log in to mysql again and type status:

As you can see, the green arrow is not UTF-8

So let’s exit mysql first, and then go to the my. CNF file under the etc directory to modify the contents of the file

After entering the file, add four lines of code:

After saving the modified my.cnf file, restart mysql and type Status to check again and you will see the changes

Start mysql with CMD on Windows!

(after)

Document address: blog.csdn.net/qq_36582604…