[root@node ~]# systemctl stop firewalld
[root@node ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@node ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@node ~]# setenforce 0 临时关闭SELINUX
[root@node ~]# getenforce
Permissive
4、安装常用软件(vim bash-completion lrzsz wget net-tools psmisc tree dos2unix)
yum install vim bash-completion lrzsz wget net-tools psmisc tree dos2unix -y
.
.
.
Complete!
5、创建快照
查看系统版本:
[root@node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
SELinux禁用状态
[root@node1 ~]# getenforce
Disabled
防火墙关闭
[root@node1 ~]# systemctl is-active firewalld.service
unknown
1、下载 MySQL Yum Repository
wget -c https://repo.mysql.com//mysql80-community-release-el7-5.noarch.rpm
2、添加 MySQL Yum Repository
yum localinstall mysql80-community-release-el7-5.noarch.rpm
.
.
.
Installed:
mysql80-community-release.noarch 0:el7-5
Complete!
3、选择安装发行版
禁用8.0:yum-config-manager --disable mysql80-community
-bash: yum-config-manager: command not found
yum -y install yum-utils
.
.
.
Installed:
yum-utils.noarch 0:1.1.31-54.el7_8
Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7_9.6 python-chardet.noarch 0:2.2.1-3.el7
python-kitchen.noarch 0:1.1.1-5.el7
Dependency Updated:
libxml2.x86_64 0:2.9.1-6.el7_9.6
Complete!
yum-config-manager --disable mysql80-community
启用5.7:yum-config-manager --enable mysql57-community
验证:
yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 230
mysql-tools-community/x86_64 MySQL Tools Community 138
mysql57-community/x86_64 MySQL 5.7 Community Server 564
4、在线安装
yum install mysql-community-server
.
.
.
Installed:
mysql-community-libs.x86_64 0:5.7.37-1.el7 mysql-community-libs-co
Dependency Installed:
mysql-community-client.x86_64 0:5.7.37-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.68-1.el7
Complete!
5、启动数据库
systemctl enable --now mysqld
6、验证
查看状态:[root@node1 ~]# systemctl status mysqld
查看端口:[root@node1 ~]# netstat -lnpt | grep :3306
查看进程:[root@node1 ~]# ps -ef | grep mysqld
查看登陆密码:
grep 'temporary password' /var/log/mysqld.log
登录:
mysql -uroot -p
退出:
\q
查看密码:
awk '/temporary password/' /var/log/mysql.log
awk '/temporary password/ {print $NF}' /var/log/mysql.log
1、事先从官网下载RPM安装包,上传至服务器:
https://repo.huaweicloud.com/mysql/Downloads/MySQL-5.7/
https://mirrors.163.com/mysql/Downloads/MySQL-5.7/
wget -c https://repo.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
ls
anaconda-ks.cfg mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
mysql-5.7.37-1.el6.x86_64.rpm-bundle.tar mysql80-community-release-el7-5.noarch.rpm
2、解压查看:
tar xf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
ll
total 1549040
-rw-------. 1 root root 1354 Mar 26 19:30 anaconda-ks.cfg
-rw-r--r-- 1 root root 494397440 Dec 16 10:16 mysql-5.7.37-1.el6.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 545894400 Dec 16 10:16 mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 10928 Jan 14 18:21 mysql80-community-release-el7-5.noarch.rpm
-rw-r--r-- 1 7155 31415 26670472 Dec 16 10:01 mysql-community-client-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 318884 Dec 16 10:01 mysql-community-common-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 4122424 Dec 16 10:01 mysql-community-devel-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 47760004 Dec 16 10:02 mysql-community-embedded-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23316972 Dec 16 10:02 mysql-community-embedded-compat-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 132204460 Dec 16 10:02 mysql-community-embedded-devel-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2474780 Dec 16 10:02 mysql-community-libs-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 1264836 Dec 16 10:02 mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 182274360 Dec 16 10:02 mysql-community-server-5.7.37-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 125477564 Dec 16 10:03 mysql-community-test-5.7.37-1.el7.x86_64.rpm
其中:
mysql-community-client 客户端
mysql-community-devel 开发库
mysql-community-common 服务端和客户端的公共文件
mysql-community-embedded 嵌入式
mysql-community-serve 服务端
mysql-community-test 测试组件
mysql-community-libs 共享库
mysql-community-libs-compat MySQL之前版本的共享兼容库
3、安装:
rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm mysql-community-common-5.7.37-1.el7.x86_64.rpm mysql-community-libs-5.7.37-1.el7.x86_64.rpm mysql-community-server-5.7.37-1.el7.x86_64.rpm
Preparing... ################################# [100%]
package mysql-community-common-5.7.37-1.el7.x86_64 is already installed
package mysql-community-libs-5.7.37-1.el7.x86_64 is already installed
package mysql-community-client-5.7.37-1.el7.x86_64 is already installed
package mysql-community-server-5.7.37-1.el7.x86_64 is already installed
如果报错:
yum remove mariadb-libs,然后进行安装
4、启动:
systemctl start mysqld
systemctl enable mysqld