Installation under mysql8.x centOS7

The first part CentOS7 install mysql
1.1 installed before cleanup work;
1.1.1 clean up the original mysql database;
use the following command to find and install the mysql package dependencies:

-by rpm | grep mysql


The results show the following:

mysql80-community-release-el7-1.noarch
mysql-community-server-8.0.11-1.el7.x86_64
mysql-community-common-8.0.11-1.el7.x86_64
mysql-community-libs-8.0.11-1.el7.x86_64
mysql-community-client-8.0.11-1.el7.x86_64


Use the following command in order to delete the above program

yum remove mysql-xxx-xxx-


Delete mysql configuration files, uninstall does not automatically delete the configuration file, first use the following command to find out the configuration file used;

find / -name mysql


It may show the following results:

/etc/logrotate.d/mysql
/etc/selinux/targeted/active/modules/100/mysql
/etc/selinux/targeted/tmp/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/bin/mysql
/usr/lib64/mysql
/usr/local/mysql


In order to delete the configuration file on demand using the following command

rm -rf /var/lib/mysql


MariaDB 1.1.2 delete files,


Since the charges in CentOS7 MySQL, it no longer supports MySQL, replaced within CentOS7 integrated mariadb, and then will install MySQL and MariaDB file conflicts, so you need to uninstall MariaDB.

Use the rpm command to find out mariadb files to be deleted;

rpm -pa | grep mariadb


It may show the following results:

mariadb-libs-5.5.56-2.el7.x86_64


Delete the above program

rpm -e mariadb-libs-5.5.56-2.el7.x86_64


Error may prompt as follows:

Dependent detection failure:

. libmysqlclient.so is 18 is () (64bit) is (installed) postfix- 2 : 2.10 . . 1 - . 6 .el7.x86_64 need

. libmysqlclient.so is 18 is (libmysqlclient_18) (64bit) is (installed) postfix- 2 : 2.10 . . 1 - . 6 .el7.x86_64 need

. libmysqlclient.so is 18 is (libmysqlclient_18) (64bit) is (installed) postfix- 2 : 2.10 . . 1 - . 6 .el7.x86_64 need


Forced Delete:

rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64


At this point some will be original and mariadb mysql database deleted;

 

1.2 install mysql
mysql repo source 1.2.1 official website provides the following mysql
yum centos source is not in default mysql, so we need to go to the official website to download and install mysql repo source;

mysql official website download link: mysql repo download the following address:

 https://dev.mysql.com/downloads/repo/yum/

1.2.2 Use the putty pscp to upload files to CentOS
use putty to F: just under a good mysql repo files uploaded to the footwall Centos / usr / local / mysql folder;

D:\Putty>pscp F:\mysql80-community-release-el7-1.noarch.rpm root@192.168.145.136:/usr/local/mysql/

(You can also use the tool to upload your own client, I use FileZilla)


1.2.3 install yum yum repo file and update the cache;

rpm -ivh mysql57-community-release-el7-11.noarch.rpm


Results of the:

It generates two repo file mysql-community.repo mysql-community-source.repo in /etc/yum.repos.d/ directory

 

Yum update command

yum clean all
yum makecache


1.2.4 Using yum install mysql


When we use yum install mysql, yum installed by default mysql latest version of GA from yum repository; how to choose your own version;

Step 1: Check mysql mysql yum repository version, use the following command

yum repolist all | grep mysql


We can see MySQL 5.5 5.6 5.7 for the disabled and MySQL 8.0 is enabled;

 

The second step uses yum-config-manager command to modify the appropriate version for the latest version enabled disabled

yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community


Or you can edit the file mysql repo,
CAT /etc/yum.repos.d/mysql-community.repo


The enabled at the appropriate version can be changed to 1;

1.2.5 mysql installation command as follows:

yum install mysql-community-server

1.2.6 open mysql Services

systemctl start mysqld.service


1.2.7 obtain the initial password mysql


mysql will create a root @ locahost accounts after installation and the initial password into the /var/log/mysqld.log file;

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

Using the initial password mysql

mysql -u root -p 


Modify the initial password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';


1.2.8 3306 open ports in the firewall
CentOS7 default firewall is used as a firewall, I've changed the habit of frequently used iptables firewall

The first step: Turn off the firewall firewall

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service


Step 2: Install iptables firewall

yum install iptables-services -y


The third step: start the firewall iptable

systemctl enable iptables
systemctl start iptables

Step four: Edit Firewall Ports on firewalls file location is: / etc / sysconfig / iptables

vim /etc/sysconfig/iptables

Increase in the third line

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT


Step five: Restart the firewall

systemctl enable iptables.service
systemctl start iptables.service

 

1.2.9 mysql service will be added to startup item, and start the process mysql

systemctl enable mysqld.service
systemctl start mysqld.service


Common mysql service command:

Log in mysql

mysql -u username -p

Exit mysql

quit

Start mysql

systemctl start mysqld.service

End

systemctl stop mysqld.service

Restart

systemctl restart mysqld.service

Boot from Kai

systemctl enable mysqld.service

Check mysql version

select version();



Original connection: https://blog.csdn.net/ManagementAndJava/article/details/80039650

Guess you like

Origin www.cnblogs.com/Mr-Rshare/p/11838470.html