欢迎访问我的个人博客网站:http://www.yanmin99.com/
一、检查mysql是否安装
- 第一种方式查看
[root@iZ2ze3nze2sw4quaa8xor9Z yanmin]# rpm -qa | grep -i mysql
php-mysql-5.3.3-49.el6.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
- 第二种方式查看
[root@iZ2ze3nze2sw4quaa8xor9Z yanmin]# yum list installed | grep mysql
mysql-libs.x86_64 5.1.73-8.el6_8 @base
php-mysql.x86_64 5.3.3-49.el6 @base
二、卸载mysql
- 1、通过yum卸载
yum -y remove mysql mysql-server mysql-libs
-
2、查看是否卸载干净
A、通过
find / -name mysql
查看[root@iZ2ze3nze2sw4quaa8xor9Z yanmin]# find / -name mysql /var/lib/mysql /var/lib/mysql/mysql
B、删除残留文件
[root@iZ2ze3nze2sw4quaa8xor9Z yanmin]# rm -rf /var/lib/mysql/
三、yum和RPM安装
-
1、通过yum安装
- 通过yum安装
yum install mysql mysql-server mysql-libs;
- 通过yum卸载
yum remove mysql mysql-server mysql-libs;
-
2、通过RPM安装
- A、直接选择一个版本到repos文件夹中
- 1、查看mysql是否存在/etc/yum.repos.d/文件夹中
yum repolist all | grep mysql
- 2、在/etc/yum.repos.d/mysql-community.repo添加mysq5.6版本
//MySQL5.6版本 # Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql //MySQL5.7版本 [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
enabled=0 禁用 enabled=1 启用
- 3、查看源是否添加成功
yum repolist enabled | grep mysql
enabled查看启用列表
- 4、安装
sudo yum install mysql-community-server
- A、直接选择一个版本到repos文件夹中
-
B、通过下载版本,本地安装
- 1、下载MySQL Yum Repository
wget --no-check-certificate https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm
- 2、添加 MySQL Yum Repository
rpm -ivh mysql57-community-release-el6-11.noarch.rpm
通过执行rpm -ivh,其实在/etc/yum.repos.d/文件夹中生成了mysql-community.repo和mysql-community-source.repo文件。
- 3、验证下是否添加成功
yum repolist all | grep mysql
-
4、选择要启用 MySQL 版本
- mysql-community.repo有常用版本,可以通过enable=1指定安装版本。
- mysql-community.repo文件如下:
[mysql-connectors-community] name=MySQL Connectors Community baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community] name=MySQL Tools Community baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.5 [mysql55-community] name=MySQL 5.5 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
-
5、安装
sudo yum install mysql-community-server