个人记录
第一步:卸载已安装的mysql
rpm -qa | grep -i mysql 查询已安装的mysql
1、确认停止mysql服务
2、删除卸载mysql
–nodeps:表示强制卸载,如果因为依赖关系导致卸载不成功,加上强制卸载选项–nodeps
rpm -ev mysql-community-server-5.7.40-1.el7.x86_64 --nodeps
如此把查询到的mysql全部删除掉
3、删除mysql文件和配置文件
#rm -rf /var/lib/mysql/mysql
#rm -rf /var/lib/mysql
#rm -rf /var/lib64/mysql
#rm -rf /etc/my.cnf
第二步:下载rpm安装文件
mysql下载地址
选择下载版本
mysql-community-server-5.7.40-1.el7.x86_64.rpm;
mysql-community-client-5.7.40-1.el7.x86_64.rpm;
mysql-community-libs-5.7.40-1.el7.x86_64.rpm;
mysql-community-libs-compat-5.7.40-1.el7.x86_64.rpm;
mysql-community-common-5.7.40-1.el7.x86_64.rpm
上传到Linux服务器,授予安装包可执行权限
chmod 755 mysql*
第三步:安装mysql
依次执行如下命令,注意命令执行的顺序
#rpm -ivh mysql-community-common-5.7.11-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-5.7.11-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-compat-5.7.11-1.el7.x86_64.rpm
#rpm -ivh mysql-community-client-5.7.11-1.el7.x86_64.rpm
#rpm -ivh mysql-community-server-5.7.11-1.el7.x86_64.rpm
注意:是依次执行,不要乱了顺序,因为它们之间有依赖关系
初始化mysql
mysqld --initialize --user=mysql
启动
systemctl restart mysqld