这是我之前安装的mysql5.7,跟着相应的操作就可以删除干净。
[root@mysql-master2 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 四 2022-11-10 00:23:37 CST; 1 day 13h ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 4941 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 4920 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 4944 (mysqld)
Tasks: 29
CGroup: /system.slice/mysqld.service
└─4944 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
11月 10 00:23:32 mysql-master2 systemd[1]: Starting MySQL Server...
11月 10 00:23:37 mysql-master2 systemd[1]: Started MySQL Server.
[root@mysql-master2 ~]# systemctl stop mysqld
[root@mysql-master2 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead) since 五 2022-11-11 13:58:05 CST; 3s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 4941 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 4920 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 4944 (code=exited, status=0/SUCCESS)
11月 10 00:23:32 mysql-master2 systemd[1]: Starting MySQL Server...
11月 10 00:23:37 mysql-master2 systemd[1]: Started MySQL Server.
11月 11 13:58:02 mysql-master2 systemd[1]: Stopping MySQL Server...
11月 11 13:58:05 mysql-master2 systemd[1]: Stopped MySQL Server.
[root@mysql-master2 ~]# rpm -qa | grep -i mysql
mysql-community-client-5.7.40-1.el7.x86_64
zabbix-web-mysql-scl-5.0.28-1.el7.noarch
mysql-community-embedded-5.7.40-1.el7.x86_64
mysql-community-embedded-devel-5.7.40-1.el7.x86_64
zabbix-server-mysql-5.0.28-1.el7.x86_64
mysql-community-server-5.7.40-1.el7.x86_64
zabbix-proxy-mysql-5.0.28-1.el7.x86_64
mysql-community-libs-5.7.40-1.el7.x86_64
mysql-community-libs-compat-5.7.40-1.el7.x86_64
rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64
mysql-community-devel-5.7.40-1.el7.x86_64
mysql-community-test-5.7.40-1.el7.x86_64
mysql-community-embedded-compat-5.7.40-1.el7.x86_64
perl-DBD-MySQL-4.023-6.el7.x86_64
mysql80-community-release-el7-7.noarch
mysql-community-common-5.7.40-1.el7.x86_64
[root@mysql-slave2 ~]# yum remove -y mysql-community*
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-common.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-devel.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-embedded.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-embedded-compat.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-embedded-devel.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-libs.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-libs-compat.x86_64.0.5.7.40-1.el7 将被 删除
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 perl-DBD-MySQL-4.023-6.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 zabbix-server-mysql-5.0.28-1.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 zabbix-proxy-mysql-5.0.28-1.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 perl-DBD-MySQL-4.023-6.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 zabbix-server-mysql-5.0.28-1.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 zabbix-proxy-mysql-5.0.28-1.el7.x86_64 需要
---> 软件包 mysql-community-server.x86_64.0.5.7.40-1.el7 将被 删除
---> 软件包 mysql-community-test.x86_64.0.5.7.40-1.el7 将被 删除
--> 正在检查事务
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-6.el7 将被 删除
---> 软件包 zabbix-proxy-mysql.x86_64.0.5.0.28-1.el7 将被 删除
---> 软件包 zabbix-server-mysql.x86_64.0.5.0.28-1.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================================================================================================
正在删除:
mysql-community-client x86_64 5.7.40-1.el7 @mysql57 108 M
mysql-community-common x86_64 5.7.40-1.el7 @mysql57 2.8 M
mysql-community-devel x86_64 5.7.40-1.el7 @mysql57-community 24 M
mysql-community-embedded x86_64 5.7.40-1.el7 @mysql57-community 201 M
mysql-community-embedded-compat x86_64 5.7.40-1.el7 @mysql57-community 88 M
mysql-community-embedded-devel x86_64 5.7.40-1.el7 @mysql57-community 906 M
mysql-community-libs x86_64 5.7.40-1.el7 @mysql57 10 M
mysql-community-libs-compat x86_64 5.7.40-1.el7 @mysql57 5.9 M
mysql-community-server x86_64 5.7.40-1.el7 @mysql57 774 M
mysql-community-test x86_64 5.7.40-1.el7 @mysql57-community 671 M
为依赖而移除:
perl-DBD-MySQL x86_64 4.023-6.el7 @base 323 k
zabbix-proxy-mysql x86_64 5.0.28-1.el7 @zabbix 4.6 M
zabbix-server-mysql x86_64 5.0.28-1.el7 @zabbix 7.1 M
事务概要
===================================================================================================================================================================================================================
移除 10 软件包 (+3 依赖软件包)
安装大小:2.7 G
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : mysql-community-embedded-devel-5.7.40-1.el7.x86_64 1/13
正在删除 : mysql-community-devel-5.7.40-1.el7.x86_64 2/13
正在删除 : mysql-community-embedded-5.7.40-1.el7.x86_64 3/13
正在删除 : mysql-community-test-5.7.40-1.el7.x86_64 4/13
正在删除 : mysql-community-server-5.7.40-1.el7.x86_64 5/13
正在删除 : mysql-community-client-5.7.40-1.el7.x86_64 6/13
正在删除 : zabbix-server-mysql-5.0.28-1.el7.x86_64 7/13
警告:/etc/zabbix/zabbix_server.conf 已另存为 /etc/zabbix/zabbix_server.conf.rpmsave
正在删除 : mysql-community-embedded-compat-5.7.40-1.el7.x86_64 8/13
正在删除 : perl-DBD-MySQL-4.023-6.el7.x86_64 9/13
正在删除 : zabbix-proxy-mysql-5.0.28-1.el7.x86_64 10/13
警告:/etc/zabbix/zabbix_proxy.conf 已另存为 /etc/zabbix/zabbix_proxy.conf.rpmsave
正在删除 : mysql-community-libs-compat-5.7.40-1.el7.x86_64 11/13
正在删除 : mysql-community-libs-5.7.40-1.el7.x86_64 12/13
正在删除 : mysql-community-common-5.7.40-1.el7.x86_64 13/13
验证中 : mysql-community-client-5.7.40-1.el7.x86_64 1/13
验证中 : zabbix-proxy-mysql-5.0.28-1.el7.x86_64 2/13
验证中 : mysql-community-devel-5.7.40-1.el7.x86_64 3/13
验证中 : mysql-community-server-5.7.40-1.el7.x86_64 4/13
验证中 : mysql-community-common-5.7.40-1.el7.x86_64 5/13
验证中 : perl-DBD-MySQL-4.023-6.el7.x86_64 6/13
验证中 : mysql-community-embedded-compat-5.7.40-1.el7.x86_64 7/13
验证中 : zabbix-server-mysql-5.0.28-1.el7.x86_64 8/13
验证中 : mysql-community-embedded-5.7.40-1.el7.x86_64 9/13
验证中 : mysql-community-libs-5.7.40-1.el7.x86_64 10/13
验证中 : mysql-community-libs-compat-5.7.40-1.el7.x86_64 11/13
验证中 : mysql-community-test-5.7.40-1.el7.x86_64 12/13
验证中 : mysql-community-embedded-devel-5.7.40-1.el7.x86_64 13/13
删除:
mysql-community-client.x86_64 0:5.7.40-1.el7 mysql-community-common.x86_64 0:5.7.40-1.el7 mysql-community-devel.x86_64 0:5.7.40-1.el7 mysql-community-embedded.x86_64 0:5.7.40-1.el7
mysql-community-embedded-compat.x86_64 0:5.7.40-1.el7 mysql-community-embedded-devel.x86_64 0:5.7.40-1.el7 mysql-community-libs.x86_64 0:5.7.40-1.el7 mysql-community-libs-compat.x86_64 0:5.7.40-1.el7
mysql-community-server.x86_64 0:5.7.40-1.el7 mysql-community-test.x86_64 0:5.7.40-1.el7
作为依赖被删除:
perl-DBD-MySQL.x86_64 0:4.023-6.el7 zabbix-proxy-mysql.x86_64 0:5.0.28-1.el7 zabbix-server-mysql.x86_64 0:5.0.28-1.el7
完毕!
[root@mysql-slave2 ~]# rpm -qa | grep -i mysql
zabbix-web-mysql-scl-5.0.28-1.el7.noarch
rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64
mysql80-community-release-el7-7.noarch
[root@mysql-slave2 ~]# yum remove -y mysql80-community-release-el7-7.noarch
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql80-community-release.noarch.0.el7-7 将被 删除
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================================================================================================
正在删除:
mysql80-community-release noarch el7-7 @/mysql80-community-release-el7-7.noarch 10 k
事务概要
===================================================================================================================================================================================================================
移除 1 软件包
安装大小:10 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : mysql80-community-release-el7-7.noarch 1/1
警告:/etc/yum.repos.d/mysql-community.repo 已另存为 /etc/yum.repos.d/mysql-community.repo.rpmsave
验证中 : mysql80-community-release-el7-7.noarch 1/1
删除:
mysql80-community-release.noarch 0:el7-7
完毕!
[root@mysql-master2 ~]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/share/mysql
[root@mysql-master2 ~]# rm -rf /etc/selinux/targeted/active/modules/100/mysql /var/lib/mysql /var/lib/mysql/mysql /usr/share/mysql
[root@mysql-slave2 ~]# find / -name mysql
[root@mysql-slave2 ~]# rm -rf /etc/my.cnf
[root@mysql-slave2 ~]# systemctl start mysql
Failed to start mysql.service: Unit not found.
[root@mysql-master2 ~]# grep password /var/log/mysqld.log
2022-11-08T06:13:24.764470Z 1 [Note] A temporary password is generated for root@localhost: jCCzW8jNPw>f
//这里更改一下数据库的密码可以更直观的感受到数据库恢复数据的过程
[root@mysql-master2 ~]# mysqladmin -uroot -p're%f<7H1bi7s' password 'guan123456'
装完mysql启动服务,第一次使用需要重置密码,显示我输入的密码"guan123456"太简单,在个人练习过程中,不想把密码设置太复杂
[root@mysql-master2 ~]# grep password /var/log/mysql.log
2022-11-08T06:13:24.764470Z 1 [Note] A temporary password is generated for root@localhost: jCCzW8jNPw>f
# mysqladmin -uroot -p"jCCzW8jNPw>f" password "guan123456"
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'
解决方案:
# mysql -uroot -p'jCCzW8jNPw>f'
(1)修改validate_password_policy参数值为0(1为开启复杂策略)
注意:此参数(policy)必须优先修改,因为policy策略不修改为0会影响下面的length参数。
mysql> set global validate_password_policy=0;
(2)修改validate_password_length参数值为1
mysql> set global validate_password_length=1;
退出重新修改密码
mysql > exit;
[root@mysql-server ~]# mysqladmin -uroot -p'jCCzW8jNPw>f' password'guan123456'