1、Linux平台上推荐使用RPM包来安装Mysql
MySQL - MySQL服务器。你需要该选项,除非你只想连接运行在另一台机器上的MySQL服务器。
MySQL-client - MySQL 客户端程序,用于连接并操作Mysql服务器。
MySQL-devel - 库和包含文件,如果你想要编译其它MySQL客户端,例如Perl模块,则需要安装该RPM包。
MySQL-shared - 该软件包包含某些语言和应用程序需要动态装载的共享库(libmysqlclient.so*),使用MySQL。
MySQL-bench - MySQL数据库服务器的基准和性能测试工具。
2、安装前,检测系统是否自带安装 MySQL、Mariadb
查询Mariadb:
[root@192 mysql]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@192 mysql]#
卸载Mariadb:
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
查询旧版mysql
rpm -qa | grep mysql #检测系统是否自带安装 MySQL
如果系统已经安装,那需要先卸载旧版本:
rpm -e mysql // 普通删除模式
rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
查询mysql文件,并将其删除:
find / -name mysql
whereis mysql
将find命令和whereis命令查询到的mysql文件全部删除:
**rm -rf 查询到的mysql路径**
删除mysql配置文件:
rm /etc/my.cnf
确认是否全部删除mysql:
rpm -qa | grep -i mysql
3、 Centos7 系统下使用 yum 命令安装 MySQL,需要注意的是 CentOS 7 版本中 MySQL数据库已从默认的程序列表中移除,所以在安装前我们需要先去官网下载 Yum 资源包,
下载地址为:https://dev.mysql.com/downloads/repo/yum/
命令:
wget http://repo.mysql.com/mysql80-community-release-el7-5.noarch.rpm
rpm -ivh mysql80-community-release-el7-5.noarch.rpm
yum -y update
yum install mysql-server
[root@localhost ~]# wget http://repo.mysql.com/mysql80-community-release-el7-5.noarch.rpm
--2022-04-08 20:26:15-- http://repo.mysql.com/mysql80-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.195.152.228
Connecting to repo.mysql.com (repo.mysql.com)|23.195.152.228|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10928 (11K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-5.noarch.rpm’
100%[=================================================================================================================================================>] 10,928 --.-K/s in 0.002s
2022-04-08 20:26:16 (4.37 MB/s) - ‘mysql80-community-release-el7-5.noarch.rpm’ saved [10928/10928]
[root@localhost ~]# rpm -ivh mysql80