如何完全删除MySQL以进行全新安装

我需要完全删除有关MySQL的所有内容。 它没有开始所以我决定删除它。 但在安装过程中发生这种情

sta@daPC:~$ sudo apt-get install mysql-server Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libdbd-mysql-perl libmysqlclient18 mysql-client-5.6 mysql-common mysql-server-5.6 Suggested packages: mailx tinyca The following NEW packages will be installed: libdbd-mysql-perl libmysqlclient18 mysql-client-5.6 mysql-common mysql-server mysql-server-5.6 0 upgraded, 6 newly installed, 0 to remove and 87 not upgraded. Need to get 0 B/12,0 MB of archives. After this operation, 101 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Preconfiguring packages ... Selecting previously unselected package mysql-common. (Reading database ... 188526 files and directories currently installed.) Preparing to unpack .../mysql-common_5.6.28-0ubuntu0.15.10.1_all.deb ... Unpacking mysql-common (5.6.28-0ubuntu0.15.10.1) ... Selecting previously unselected package libmysqlclient18:i386. Preparing to unpack .../libmysqlclient18_5.6.28-0ubuntu0.15.10.1_i386.deb ... Unpacking libmysqlclient18:i386 (5.6.28-0ubuntu0.15.10.1) ... Selecting previously unselected package libdbd-mysql-perl. Preparing to unpack .../libdbd-mysql-perl_4.028-2_i386.deb ... Unpacking libdbd-mysql-perl (4.028-2) ... Selecting previously unselected package mysql-client-5.6. Preparing to unpack .../mysql-client-5.6_5.6.28-0ubuntu0.15.10.1_i386.deb ... Unpacking mysql-client-5.6 (5.6.28-0ubuntu0.15.10.1) ... Processing triggers for man-db (2.7.4-1) ... Setting up mysql-common (5.6.28-0ubuntu0.15.10.1) ... update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode Selecting previously unselected package mysql-server-5.6. (Reading database ... 188621 files and directories currently installed.) Preparing to unpack .../mysql-server-5.6_5.6.28-0ubuntu0.15.10.1_i386.deb ... Unpacking mysql-server-5.6 (5.6.28-0ubuntu0.15.10.1) ... Selecting previously unselected package mysql-server. Preparing to unpack .../mysql-server_5.6.28-0ubuntu0.15.10.1_all.deb ... Unpacking mysql-server (5.6.28-0ubuntu0.15.10.1) ... Processing triggers for man-db (2.7.4-1) ... Processing triggers for ureadahead (0.100.0-19) ... ureadahead will be reprofiled on next reboot Processing triggers for systemd (225-1ubuntu9) ... Setting up libmysqlclient18:i386 (5.6.28-0ubuntu0.15.10.1) ... Setting up libdbd-mysql-perl (4.028-2) ... Setting up mysql-client-5.6 (5.6.28-0ubuntu0.15.10.1) ... Setting up mysql-server-5.6 (5.6.28-0ubuntu0.15.10.1) ... update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode 2016-02-17 04:13:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-02-17 04:13:48 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-0ubuntu0.15.10.1) starting as process 13491 ... 

正如您所看到的,它再次停止启动MySQL服务器。 如何彻底删除MySQL以进行全新安装?

编辑:重新启动计算机后问题自行解决。 由于我既没有发现问题也没有检测到实际解决方案,因此我不会将其作为答案发布。

我找到了一个解决方案: https : //stackoverflow.com/questions/25244606/completely-remove-mysql-ubuntu-14-04-lts/28113482#28113482

 sudo rm -rf /var/lib/mysql/mysql sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get autoremove sudo apt-get autoclean sudo apt-get install mysql-server 

在重新安装过程中,系统提示我输入(新)密码。 在不成功的先前重新安装期间,我让它为空,并且mysql保留了之前安装的旧忘记密码,我认为这是空的。

dpkg -P包应该完全清除包,包括配置文件。 以下是man dpkg命令中的选项说明

-r, – remove,-P, – purge package … | -a | –pending删除已安装的包。 -r或–remove删除除了conffiles之外的所有内容。 如果稍后重新安装,则可以避免重新配置包装年龄。 (配额是DEBIAN / conffiles控制文件中列出的配置文件)。 -P或–purge删除所有内容,包括conffiles。 如果给出-a或–pending而不是包名,则分别删除或清除所有已解包但标记为在文件/ var / lib / dpkg / status中删除或清除的包。 注意:dpkg可能不知道某些配置文件,因为它们是通过配置脚本单独创建和处理的。 在这种情况下,dpkg不会自行删除它们,但是包的postrm脚本(由dpkg调用)必须在清除期间处理它们的删除。 当然,这仅适用于系统目录中的文件,而不适用于写入各个用户主目录的配置文件。

你必须使用清除:

  remove remove is identical to install except that packages are removed instead of installed. Note the removing a package leaves its configuration files in system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed. purge purge is identical to remove except that packages are removed and purged (any configuration files are deleted too). --purge Use purge instead of remove for anything that would be removed. An asterisk ("*") will be displayed next to packages which are scheduled to be purged. remove --purge is equivalent for purge command. Configuration Item: APT::Get::Purge. 

句法:

  sudo apt-get remove --purge  

或其等价物:

  sudo apt-get purge  

希望能帮助到你。