Linux下删除Mysql

1、检查mysql服务并关闭相应的进程

[root@bp18425116f0cojd1vnz ~]# ps -ef |grep mysql

root 1492 1 0 10:23 ? 00:00:00 /bin/sh /www/server/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/www/server/data --pid-file=/www/server/data/bp18425116f0cojd1vnz.pid

mysql 2759 1492 0 10:23 ? 00:00:00 /www/server/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/www/server/mysql --datadir=/www/server/data --plugin-dir=/www/server/mysql/lib/plugin --user=mysql --log-error=bp18425116f0cojd1vnz.err --open-files-limit=65535 --pid-file=/www/server/data/bp18425116f0cojd1vnz.pid --socket=/tmp/mysql.sock --port=3306

root 3117 3072 0 10:34 pts/0 00:00:00 grep --color=auto mysql

[root@bp18425116f0cojd1vnz ~]# systemctl status mysql

● mysql.service - LSB: start and stop MySQL

Loaded: loaded (/etc/rc.d/init.d/mysql; generated)

Active: active (exited) since Wed 2022-02-09 10:23:35 CST; 10min ago

Docs: man:systemd-sysv-generator(8)

Process: 1416 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)

Feb 09 10:23:30 bp18425116f0cojd1vnz systemd[1]: Starting LSB: start and stop MySQL...

Feb 09 10:23:33 bp18425116f0cojd1vnz mysql[1416]: Starting MySQL...Logging to '/www/server/data/bp18425116f0cojd1vnz.err'.

Feb 09 10:23:35 bp18425116f0cojd1vnz mysql[1416]: .[ OK ]

Feb 09 10:23:35 bp18425116f0cojd1vnz systemd[1]: Started LSB: start and stop MySQL.

Feb 09 10:25:15 bp18425116f0cojd1vnz mysql[1416]: 2022-02-09T02:25:15.316976Z mysqld_safe A mysqld process with pid=2759 is already running. Aborting!!

[root@bp18425116f0cojd1vnz ~]# systemctl stop mysql

2、再次检查Mysql服务的状态

[root@bp18425116f0cojd1vnz ~]# systemctl status mysql

● mysql.service - LSB: start and stop MySQL

Loaded: loaded (/etc/rc.d/init.d/mysql; generated)

Active: inactive (dead) since Wed 2022-02-09 10:35:42 CST; 4sago

Docs: man:systemd-sysv-generator(8)

Process: 3126 ExecStop=/etc/rc.d/init.d/mysql stop (code=exited, status=0/SUCCESS)

Process: 1416 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)

Feb 09 10:23:30 bp18425116f0cojd1vnz systemd[1]: Starting LSB: start and stop MySQL...

Feb 09 10:23:33 bp18425116f0cojd1vnz mysql[1416]: Starting MySQL...Logging to '/www/server/data/bp18425116f0cojd1vnz.err'.

Feb 09 10:23:35 bp18425116f0cojd1vnz mysql[1416]: .[ OK ]

Feb 09 10:23:35 bp18425116f0cojd1vnz systemd[1]: Started LSB: start and stop MySQL.

Feb 09 10:25:15 bp18425116f0cojd1vnz mysql[1416]: 2022-02-09T02:25:15.316976Z mysqld_safe A mysqld process with pid=2759 is already running. Aborting!!

Feb 09 10:35:40 bp18425116f0cojd1vnz systemd[1]: Stopping LSB: start and stop MySQL...

Feb 09 10:35:42 bp18425116f0cojd1vnz mysql[3126]: Shutting down MySQL..[ OK ]

Feb 09 10:35:42 bp18425116f0cojd1vnz systemd[1]: mysql.service: Succeeded.

Feb 09 10:35:42 bp18425116f0cojd1vnz systemd[1]: Stopped LSB: start and stop MySQL.

3、查找Mysql的安装目录并彻底删除

[root@bp18425116f0cojd1vnz ~]# find / -name mysql

/usr/include/mysql

/usr/bin/mysql

/usr/lib/mysql

/etc/rc.d/init.d/mysql

/www/server/panel/install/mysql

/www/server/mysql

/www/server/mysql/include/mysql

/www/server/mysql/bin/mysql

/www/server/data/mysql

4、删除Mysql的安装目录

[root@bp18425116f0cojd1vnz ~]# rm -rf /usr/local/mysql /usr/include/mysql /usr/bin/mysql /usr/lib/mysql /www/server/panel/install/mysql

[root@bp18425116f0cojd1vnz ~]# rm -rf /www/server/mysql /www/server/mysql/include/mysql /www/server/mysql/bin/mysql /www/server/data/mysql

5、删除Mysql的配置文件

[root@bp18425116f0cojd1vnz ~]# rm -rf /etc/rc.d/init.d/mysql

6、删除Mysql的用户组

[root@bp18425116f0cojd1vnz ~]# id mysql

uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)

[root@bp18425116f0cojd1vnz ~]# userdel mysql

以上是 Linux下删除Mysql 的全部内容, 来源链接: utcz.com/z/267476.html

回到顶部