欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

在Ubuntu或Debian系统的服务器上卸载MySQL的方法

程序员文章站 2024-03-31 12:54:40
对于有的vps,系统默认安装了mysql。我们需要从我们的服务器、vps上卸载(移除)默认的mysql。那么如何(怎样)在ubuntu\debian上卸载mysql?...

对于有的vps,系统默认安装了mysql。我们需要从我们的服务器、vps上卸载(移除)默认的mysql。那么如何(怎样)在ubuntu\debian上卸载mysql?

通常情况下,下列mysql软件包会被安装到 debian 、ubuntu中:

  • mysql-client - the latest version of mysql database client(最新版的mysql数据库客户端).
  • mysql-server - the latest version of mysql database server.(最新版的mysql数据库服务端)
  • mysql-common - mysql database common files(mysql数据库命令文件)

那么如何怎样在ubuntu\debian上卸载mysql?
只需要使用 apt-get 命令 即可,如下面的命令,同时卸载 ubuntu \ debian 中的 mysql server 和 mysql client :

sudo apt-get --purge remove mysql-client mysql-server mysql-common
sudo apt-get autoremove

解释: --purge 移除所给的软件包和配置文件

remove 表示卸载软件包

autoremove 表示自动卸载软件包,以及与该软件包的依赖(软件包)

输入如下(注意软件包名字):

reading package lists... done
building dependency tree
reading state information... done
the following packages were automatically installed and are no longer required:
 linux-headers-3.2.0-31-virtual linux-headers-3.2.0-31
use 'apt-get autoremove' to remove them.
the following packages will be removed:
 libdbd-mysql-perl* libmysqlclient18* mysql-client* mysql-client-5.5* mysql-common* mysql-server*
 mysql-server-5.5*
0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
after this operation, 67.5 mb disk space will be freed.
do you want to continue [y/n]? y
(reading database ... 105097 files and directories currently installed.)
removing mysql-server ...
removing mysql-server-5.5 ...
mysql stop/waiting
purging configuration files for mysql-server-5.5 ...
removing mysql-client ...
removing mysql-client-5.5 ...
removing libdbd-mysql-perl ...
removing libmysqlclient18 ...
purging configuration files for libmysqlclient18 ...
removing mysql-common ...
purging configuration files for mysql-common ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed.
processing triggers for ureadahead ...
processing triggers for man-db ...
processing triggers for libc-bin ...
ldconfig deferred processing now taking place

删除 /etc/mysql 目录,使用如下命令:

sudo rm -rf /etc/mysql/  

解释:-r 同时删除该目录下的所有子目录。 -f 表示强制删除