查看当前系统mysql 运行状态
[root@zendlinux ~]# ps -ef |grep mysql
root 1153 1 0 15:40 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/zendlinux.pid
mysql 1695 1153 0 15:40 ? 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/var/zendlinux.err --open-files-limit=65535 --pid-file=/usr/local/mysql/var/zendlinux.pid --socket=/tmp/mysql.sock --port=3306
root 1736 1716 0 15:53 pts/0 00:00:00 grep mysql
查看mysqld状态,并关闭
[root@zendlinux ~]# service mysqld status
SUCCESS! MySQL running (1695)
[root@zendlinux ~]# service mysqld stop
Shutting down MySQL. SUCCESS!
查看开机启动情况
[root@zendlinux ~]# chkconfig --list |grep -i mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
查找MySQL的安装目录并彻底删除
[root@zendlinux ~]# whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /usr/include/mysql /usr/local/mysql
[root@zendlinux ~]# find / -name mysql
/var/spool/mail/mysql
/usr/lib/mysql
/usr/include/mysql
/usr/local/mysql
/usr/local/mysql/var/mysql
/usr/local/mysql/include/mysql
/usr/local/mysql/bin/mysql
/usr/bin/mysql
[root@zendlinux ~]# rm -rf /usr/bin/mysql /usr/local/mysql /usr/include/mysql /var/spool/mail/mysql /usr/lib/mysql
[root@zendlinux ~]# find / -name mysql
删除一些配置文件
配置文件一般有/etc/my.cnf 或/etc/init.d/mysqld,视具体安装配置情况而定。
[root@zendlinux ~]# rm -rf /etc/my.cnf
[root@zendlinux ~]# rm -rf /etc/init.d/mysqld
删除MySQL用户以及用户组
[root@zendlinux ~]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
[root@zendlinux ~]# userdel mysql
[root@zendlinux ~]# id mysql