1

I installed MySQL 5.6.17 using binary file *.tar.gz. I need to remove MySQL from my Ubuntu system. I tried running the following commands:

1) sudo apt-get remove --purge mysql-server mysql-client mysql-common
2) sudo apt-get autoremove
3) sudo apt-get autoclean
4) sudo deluser mysql
5) sudo rm -rf /var/lib/mysql

When the I execute the first command nothing seems to happen. Here is the output:

1)

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package mysql-client is not installed, so not removed
Package mysql-common is not installed, so not removed
Package mysql-server is not installed, so not removed

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

2)

Reading package lists... Done
Building dependency tree       
Reading state information... Done

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

3)

Reading package lists... Done
Building dependency tree       
Reading state information... Done

4)

Removing user `mysql' ...
Warning: group `mysql' has no more members.
userdel: user mysql is currently logged in
/usr/sbin/deluser: `/usr/sbin/userdel mysql' returned error code 8. Exiting.

5)

Executes. The directory is removed.

I am confused as to why it says Package mysql-server is not installed, so not removed. I tried other names such as mysql-server-5.6, mysql-server-5.6.17 but nothing seems to work. Can someone please help me with this?

I will really appreciate it.

Thanks.

1 Answer 1

1

I understand you've manually installed MySQL, without using apt. Any program you install manually is not registered by apt, so apt can't remove it.

You can prevent MySQL from starting by stopping MySQL and then removing the init script.

sudo update-rc.d -f mysql.server remove

Replace mysql.server by the name of MySQL's init script.

Now MySQL is stopped you can remove the user:

sudo deluser mysql

The only thing left are MySQL's files. If you want to save space you can remove them.

3
  • Hi Louis, I tried to execute "sudo update-rc.d -f mysql.server remove". The name of mysql's init script is "mysql.server" which i found in my my /usr/local/mysql/support-files. I get the following output: Removing any system startup links for /etc/init.d/mysql.server ... /etc/rc0.d/K20mysql.server /etc/rc1.d/K20mysql.server /etc/rc2.d/S20mysql.server /etc/rc3.d/S20mysql.server /etc/rc4.d/S20mysql.server /etc/rc5.d/S20mysql.server /etc/rc6.d/K20mysql.server...
    – srai
    Apr 26, 2014 at 22:47
  • I tried the command "sudo deluser mysql" but it returned " Removing user mysql' ... Warning: group mysql' has no more members. userdel: user mysql is currently logged in /usr/sbin/deluser: `/usr/sbin/userdel mysql' returned error code 8. Exiting. I tried to get the pid of user mysql and tried to kill it and delete it but no success. Can you please guide me? Thanks
    – srai
    Apr 26, 2014 at 22:51
  • Your MySQL init script has been removed now. MySQL won't start on boot anymore. Have you stopped MySQL before removing the init script? If not, reboot your PC (or use pkill -u mysql) and try sudo deluser mysql again. Apr 26, 2014 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .