TEL:
centos6.8 mysql5.7 rpm安装与完全卸载
| 发布时间: 2021-02-06 13:06:13 | 1774 次浏览

一、查看centos版本
cat /etc/issue
安装mysql5.7
#下载rpm包 
wget http://soft.71t.com.cn:81/soft/mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar
#创建mysql目录 
mkdir /home/mysql
#解压 
tar -xvf mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar -C /home/mysql
#安装numactl和mysql 
yum install -y numactl
cd /home/mysql
按以下顺序安装相关rpm:
安装cdh时需要
[root@azkaban mysql]# rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpm --force --nodeps 
warning: mysql-community-common-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%] 
1:mysql-community-common ########################################### [100%] 


[root@azkaban mysql]# rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm --force --nodeps 
warning: mysql-community-libs-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%] 
1:mysql-community-libs ########################################### [100%] 


[root@slave03 mysql]# rpm -ivh mysql-community-libs-compat-5.7.19-1.el6.x86_64.rpm --force --nodeps 
warning: mysql-community-libs-compat-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%] 
1:mysql-community-libs-co########################################### [100%] 


[root@azkaban mysql]# rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm --force --nodeps 
warning: mysql-community-client-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%] 
1:mysql-community-client ########################################### [100%] 


[root@azkaban mysql]# rpm -ivh mysql-community-server-5.7.19-1.el6.x86_64.rpm --force --nodeps 
warning: mysql-community-server-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%] 
1:mysql-community-server ########################################### [100%] 
#启动mysql 
service mysqld start
#查看默认生成的密码 
sudo grep 'temporary password' /var/log/mysqld.log
#登陆mysql 
mysql -uroot -p
#第一次重设密码 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPasswd4!';
#修改host值 
mysql>use mysql;
mysql> update user set host = '%' where user ='root';
mysql>flush privileges;
mysql> select host,user from user where user='root';
#修改为简单密码 
#只验证密码长度 
set global validate_password_policy=0;
mysql>flush privileges;
#查看密码长度 
select @@validate_password_length;
修改默认密码的长度(这里修改为6)
set global validate_password_length=6;
mysql>flush privileges;
#重设密码为passwd 
ALTER USER 'root'@'%' IDENTIFIED BY 'passwd';
mysql>flush privileges;
exit;
#设置开机自启动 
chkconfig mysqld on 
#重新用新密码登陆 
mysql -uroot -ppasswd
mysql>  Grant all privileges on *.* to 'root'@'%' identified by 'passwd' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


centos下完全卸载mysql


 


yum -y remove mysql-libs-*


使用Yum安装东西时,如果有强制退出过yum或yum异常结束,再下次使用yum命令时会提示:There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them。
可以通过以下方法处理:


yum -y install yum-utils


yum clean all


yum-complete-transaction --cleanup-only


 


一 、yum方式安装的mysql


yum remove mysql mysql-server mysql-libs compat-mysql51
 
rm -rf /var/lib/mysql
 
rm /etc/my.cnf
查看是否还有mysql软件:


rpm -qa|grep mysql
如果存在的话,继续删除即可。


 


二、rpm方式安装的mysql


a)查看系统中是否以rpm包安装的mysql:


[root@azkaban mysql]# rpm -qa | grep -i mysql
mysql-community-libs-5.7.19-1.el6.x86_64
mysql-community-client-5.7.19-1.el6.x86_64
mysql-community-server-5.7.19-1.el6.x86_64
mysql-community-common-5.7.19-1.el6.x86_64
b)依次卸载mysql


[root@azkaban mysql]#rpm -e mysql-community-libs-5.7.19-1.el6.x86_64
[root@azkaban mysql]# rpm -e ...
c)删除mysql服务


[root@azkaban mysql]# chkconfig --list | grep -i mysql
[root@azkaban mysql]# chkconfig --del mysql
d)删除分散mysql文件夹


[root@azkaban mysql]#  whereis mysql  
 
mysql: /usr/lib/mysql   /usr/share/mysql
清空相关mysql的所有目录以及文件


rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
[root@azkaban mysql]#find / -name mysql
 
rm -rf  ...
通过以上几步,mysql应该已经完全卸载干净了。