一:查看是否自带mariadb数据库
命令:rpm -qa | grep mariadb
如果自带数据库则卸载掉重新安装
命令:yum remove mariadb-connector-c-3.1.11-2.el8_3.x86_64
二:下载mysql
命令:wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
注意:如果出现No such file or directory,运行命令:su root
三:安装 Mysql 包
命令:yum -y install mysql57-community-release-el7-10.noarch.rpm
四:安装mysql
命令:yum -y install mysql-community-server
注意:Unable to find a match: mysql-community-server 命令:yum module disable mysql
注意:GPG不匹配 命令: rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
五:安装完成
1.启动mysql 命令:systemctl start mysqld.service
2.查看 Mysql 运行状态 命令:service mysqld status
3.查看root密码 命令:grep 'password' /var/log/mysqld.log
4.登录 命令:mysql -u root -p
5.修改密码 命令:ALTER USER USER() IDENTIFIED BY '****';