测试环境说明:
[root@linuxpg53 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@linuxpg53 ~]# mysql --version
mysql Ver 14.14 Distrib 5.7.30, for linux-glibc2.12 (x86_64) using EditLine wrapper
mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.30, for linux-glibc2.12 (x86_64) using EditLine wrapper
Connection id: 5
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.30-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 2 min 22 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 108 Flush tables: 1 Open tables: 101 Queries per second avg: 0.060
--------------
mysql>
检查 MySQL 服务并关闭服务进程
--检查mysql服务
[root@linuxpg53 ~]# ps -ef |grep mysql
mysql 10801 1 0 18:11 ? 00:00:03 /mysql/app/mysql/bin/mysqld --defaults-file=/mysql/data/3306/my.cnf
root 11308 10622 0 18:31 pts/0 00:00:00 grep --color=auto mysql
[root@linuxpg53 ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2023-09-01 18:11:23 CST; 20min ago
Docs: man:mysqld(5)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 10801 (mysqld)
Tasks: 28
CGroup: /system.slice/mysqld.service
└─10801 /mysql/app/mysql/bin/mysqld --defaults-file=/mysql/data/3306/my.cnf
Sep 01 18:11:23 linuxpg53 systemd[1]: Started MySQL Server.
--关闭mysql服务
[root@linuxpg53 ~]# systemctl stop mysqld.service
[root@linuxpg53 ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(5)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Sep 01 18:11:23 linuxpg53 systemd[1]: Started MySQL Server.
Sep 01 18:33:35 linuxpg53 systemd[1]: Stopping MySQL Server...
Sep 01 18:33:37 linuxpg53 systemd[1]: Stopped MySQL Server.
[root@linuxpg53 ~]# ps -ef |grep mysql
root 11343 10622 0 18:33 pts/0 00:00:00 grep --color=auto mysql
查找 MySQL相关目录并彻底删除
--查找:
[root@linuxpg53 mysql]# whereis mysql
mysql: /usr/lib64/mysql /usr/share/mysql /mysql/app/mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql
[root@linuxpg53 mysql]# which mysql
/mysql/app/mysql/bin/mysql
[root@linuxpg53 mysql]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/pcp/config/pmlogconf/mysql
/usr/lib64/mysql
/usr/lib64/perl5/vendor_perl/auto/DBD/mysql
/usr/lib64/perl5/vendor_perl/DBD/mysql
/usr/share/mysql
/mysql
/mysql/app/mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql
/mysql/app/mysql-5.7.30-linux-glibc2.12-x86_64/include/mysql
/mysql/app/mysql-5.7.30-linux-glibc2.12-x86_64/mysql
/mysql/app/mysql
/mysql/data/3306/data/mysql
--删除:
[root@linuxpg53 ~]# rm -rf /etc/selinux/targeted/active/modules/100/mysql
[root@linuxpg53 ~]# rm -rf /var/lib/pcp/config/pmlogconf/mysql
[root@linuxpg53 ~]# rm -rf /usr/lib64/mysql
[root@linuxpg53 ~]# rm -rf /usr/lib64/perl5/vendor_perl/auto/DBD/mysql
[root@linuxpg53 ~]# rm -rf /usr/lib64/perl5/vendor_perl/DBD/mysql
[root@linuxpg53 ~]# rm -rf /usr/share/mysql
[root@linuxpg53 ~]# rm -rf /mysql
[root@linuxpg53 ~]# find / -name mysql
删除其他配置文件
配置文件一般有 /etc/my.cnf 、mysql.sock 等,视具体安装配置情况而定。
rm -rf /etc/my.cnf
rm -rf /tmp/mysql.sock
...
删除 MySQL 用户以及用户组
[root@linuxpg53 ~]# id mysql
uid=987(mysql) gid=1002(mysql) groups=1002(mysql)
[root@linuxpg53 ~]# userdel -r mysql
userdel: mysql mail spool (/var/spool/mail/mysql) not found
userdel: mysql home directory (/home/mysql) not found
至此Linux完全卸载MySQL(二进制包/源码 安装方式)测试完成。
标签:linuxpg53,Linux,mysql,源码,mysqld,usr,MySQL,root From: https://blog.51cto.com/u_11585528/7323318