1、下載并安裝MySQL官方的 Yum Repository
[root@node1 ~]# wget -c https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
2、添加 MySQL Yum Repository
[root@node1 ~]# yum localinstall mysql80-community-release-el7-5.noarch.rpm -y
3、選擇安裝發行版
前提: 安裝YUM?
[root@node1 ~]# yum-config-manager --disable mysql80-community ? #禁用8.0
[root@node1 ~]# yum-config-manager --enable mysql57-community ? ?#啟用5.7
驗證
[root@node1 ~]# yum repolist enabled | grep -i ^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、在線安裝
[root@node1 ~]# yum install -y mysql-community-server
5、啟動數據庫
[root@node1 ~]# systemctl enable --now mysqld
6、登陸
[root@node1 ~]# tmp_pwd=`awk '/temporary password/ {print $NF}' /var/log/mysqld.log`
[root@node1 ~]# mysql -uroot -p$tmp_pwd
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
?