0

I was trying to uninstall mysql using sudo apt-get --purge remove mysql-server but getting following error

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

So I prompted to kill all running mysql processes.For this I did ps -ef | grep mysql and get

root      4473     1  0 17:46 ?        00:00:00 /bin/bash /usr/share/mysql/mysql-systemd-start post
root      4636  3783  0 17:46 pts/6    00:00:00 grep --color=auto mysql
root@viji-Latitude-E5440:~# sudo kill -9 4473
root@viji-Latitude-E5440:~# ps -ef | grep mysql
root      4672     1  0 17:47 ?        00:00:00 /bin/bash /usr/share/mysql/mysql-systemd-start post
root      4745  3783  0 17:47 pts/6    00:00:00 grep --color=auto mysql

I am trying to kill this mysql process but not able to do.
What should I do now?

js_248
  • 137
  • 1
    Please have a look at the answers here http://askubuntu.com/questions/15433/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process – efthialex May 20 '16 at 13:31
  • It looks like something might be locking up apt instead of MySQL. Eg, you try to install software while the software updater is still doing something. – Gladen May 20 '16 at 14:27

1 Answers1

2

You are entirely able to kill the process, but it seems to be starting itself again. If you notice, the PID is changing each time that you kill it. Something on your system is automatically starting it on your behalf. You have a couple of options:

  • Seek and destroy whatever is starting it (usually some sort of web control panel like XAMPP, probably in this case your service manager)
  • Boot into a shell and kill it from there (using recovery mode)

I prefer the latter, since I don't know how you installed mysql to begin with, but if you did use something similar to XAMPP, it's worth opening the control panel and trying to stop MySQL from within (even if that means re-installing the control panel software).

If you want to go with the former, you can try sudo service mysql-server stop and see if after this you can uninstall it.

XtrmJosh
  • 363
  • I am doing these in ubuntu and installed mysql using terminal .How to find the process which is starting this killed process again? – js_248 May 20 '16 at 12:55
  • Possibly the first thing to try is service mysql-server stop. You will need root permissions (sudo). This might also let you remove it using apt-get. The reason this might work is because the table you see in the result of ps aux is laid out "user", PID, PPID, some other stuff. PID and PPID are the important ones. PID is the process ID, PPID is the Parent Process ID... When the PPID is 1, it was started by the system itself. This implies that it's being run as a service, thus this might work. To help your understanding, your terminal process ID was 3783 (see next to 4745 in your output). – XtrmJosh May 20 '16 at 13:17