- 在本地下载 tar 安装包(其他版本更换链接即可),下载完成后上传到服务器
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar
- CentOS 7 默认是 mariadb 数据库,安装mysql之前要先卸载 mariadb
//获取 Mariadb 版本
rpm -qa | grep mariadb
// Mariadb 有依赖,需强制卸载
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
- 安装mysql-community-common,此行和以下几行需按顺序安装
rpm -ivh mysql-community-common-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.31-1.el7.x86_64.rpm
systemctl status mysqld
systemctl start mysqld
systemctl enable mysqld
grep "password" /var/log/mysqld.log
mysql -uroot -p3_iQaHKlheu.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test.passwd';
mysql> exit
mysql -uroot -pTest.passwd
mysql> show databases;