CentOS7 install MySQL (full version)

 

In the default CentOS installed MariaDB, MySQL is the branch, but the need for, or to install MySQL in the system, and after the installation is complete, you can directly overwrite MariaDB.

 

1 Download and install the MySQL official Yum Repository

[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

 

  Using the above command directly download the installation of Yum Repository, looks about 25KB, and then you can directly install yum.

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

 

Then began installing MySQL server.

[root@localhost ~]# yum -y install mysql-community-server

This step may take some time, it will overwrite mariadb before the installation is complete.

At this point MySQL installation is complete, then some set of MySQL.

2 MySQL database settings

  First start MySQL

 

   

 

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

  View MySQL running, running state is shown:

 

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

At this time, MySQL has started running, but in order to enter at this time MySQL had to first find out the root user password, you can find the password in the log file with the following command:

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

  The following command into the database:

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

Enter the initial password ( a picture above the rearmost NO; E 5 >> alfg! ), This time can not do anything, because the default MySQL database must be modified to operate after Password:

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

Where 'new password' to be replaced with a password you set Note: password must be uppercase and lowercase letters numbers and special symbols (, / ';: etc.), or can not be configured successfully

 

3 open mysql remote access

Execute the following command to turn on remote access restrictions (Note: The following open command IP is 192.168.0.1, To Open All, in% 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 firewalld

Add mysql port 3306 and port 8080 Tomcat

[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 mysql language

First log back mysql, and then enter the status:

 

You can see the green arrow is not utf-8

 

So let's quit mysql, and then to modify it under the my.cnf file under the etc directory file content

After entering the file, add four lines of code:

After saving the file my.cnf changes, restart under mysql, and then enter to view the status again, you will find that it changes

 

 

 

Finally, to the Windows start mysql command with cmd it! !

Original Address: https: //blog.csdn.net/qq_36582604/article/details/80526287

Guess you like

Origin www.cnblogs.com/jpfss/p/12013325.html