When I attempt to do the following:

sudo apt-get update
sudo apt-get upgrade

on my Ubuntu Server 10.04 installation, it hangs at the following line:

Preparing to replace mysql-server-5.1 5.1.41-3ubuntu12.1 (using .../mysql-server-5.1_5.1.41-3ubuntu12.3_i386.deb)

I cannot even CTRL-C out of it! I end up having to kill my session and log in from a different terminal and the upgrade process is still running. I have rebooted it several times and when I go back and try again it tells me:

E: dpkg was interrupted, you must manually run 'sudo --configure -a' to correct the problem.

Once I do that I am back at square one and it freezes up when I try to upgrade mySQL.

  • 1
    and, this would be you too... newyork.ubuntuforums.org/showthread.php?t=1514195 – nik Jun 21 '10 at 2:37
  • 2
    @nik: and? he shouldn't ask one question in two places? it is good to post in two places? you are showing that you know how to use Google? – msw Jun 21 '10 at 5:45
  • 2
    @msw, It was not a negative comment or a show off. In fact, I thought I found another reference to a similar problem.. but, turned out to be not that way. – nik Jun 21 '10 at 6:40
  • @msw: Cross-Posting is...controversial. Of course it maxes out the possibility that you get an answer, but there will be also different 'teams' working on the same thing, probably coming up with the same suggestions and just wasting their time. – Bobby Jun 21 '10 at 13:31
  • The reason I posted here was because I am not getting a single response on ubuntuforums.org. Needless to say, I won't be using them as a tech resource from now on :) – Rob Jun 21 '10 at 14:12

Try going a level below apt, after backing up your databases:

sudo dpkg -r mysql-server
sudo apt-get check    # verify that apt's metadata is okay
sudo apt-get install mysql-server


Since dpkg -r is choking try dpkg --purge and failing that get the package contents with dpkg -L mysql-server-5.1 zap them and then muck about in /var/lib/dpkg.

I've never seen things get that hairy, sorry.

if at first you don't succeed

I'm sorta thinking aloud here, forgive me. The mysql-server meta-package contains or requires these packages:


The meta-data for package management is delightfully decoupled, there are central repositories but the packages stand alone. /var/cache/apt/archives is where *.deb files that have been installed live.

First, force dpkg to forget about these packages (at the risk of failure to remove some files that we're going to replace anyway).

for i in mysql-server-core-5.1 mysql-server-5.1 ... ; do
    sudo dpkg -r --force-remove-reinstreq $i

Then get the .deb files needed for a full install:

sudo apt-get install --download-only mysql-server

and then try installing them one by one:

cd /var/cache/apt/archives
sudo dpkg -i mysql-server-core-5.1_5.1.41-3ubuntu12.3_i386.deb

if you have problems there, try:

sudo dpkg -D77777 -i mysql-server-core-5.1... > 2>&1 /tmp/dpkg.log.$$

And try and find the relevant lines out of the zillion in the logfile and post them here. Good luck and godspeed.

| improve this answer | |
  • When I do "dpkg -r mysql-server" it says it's not installed. So I then try "dpkg -r mysql-server-5.1" and it says: Package is in a very bad inconsistent state - you should reinstall it before attempting a removal. – Rob Jun 21 '10 at 13:01
  • I assume you tried "dpkg -r mysql-server-5.1" and failed? – msw Jun 21 '10 at 13:12
  • Yeah it fails. It recognizes that it's there, but says "Package is in a very bad inconsistent state - you should reinstall it before attempting a removal." – Rob Jun 21 '10 at 13:26
  • "dpkg --purge" gives the same error. So should I just delete all of the files listed with "dpkg -L mysql-server-5.1"? And what do you mean by "muck" about in /var/lib/dpkg? – Rob Jun 21 '10 at 14:17
  • added next phase – msw Jun 21 '10 at 17:06

Apparently the update is waiting for the server to start and for some reason it does not. To fix the problem there are several possibilities.

The easiest:

  1. Open a new terminal, and run:

    sudo services mysql start

More complicated but sometimes necessary: (this is handy when you do not have access to another terminal):

  1. Press "^z" (Ctrl + Z) which will "STOP" your job. Then run:

    sudo services mysql start
  2. Once the server is started type the following and hit Enter:


    This will place your "STOPPED" job back in the foreground and continue where it left off.

| improve this answer | |
  • In my case, it was indeed waiting for the server to start. – izak Aug 18 '14 at 17:10
  • Even though the start command said it was already running, within a few seconds apt-get continued fine. Thanks – Liam Wheldon May 24 '18 at 10:36

I was having this problem because it was a copy of a VM so I had changed the IP address of the server but didn't change the bind-address in the my.cnf file. Once I changed the bind-address to match, the update didn't hang and completed successfully.

| improve this answer | |

I faced the same problem and I spent more than a day debugging it.

When I removed the database directory, /var/lib/mysql/, the installation went smoothly.

| improve this answer | |
  • 2
    That should be done with caution though, right? – slhck Aug 8 '11 at 21:20

I was having this exact issue but none of the existing solutions seemed appropriate. Forcing an uninstall is supposed to be unnecessary in any *nix and is definitely not KISS. In my case I found that the cause was simple. MySQL was refusing to start because it was still running! When apt tried to stop MySQL, it was active and never actually stopped.

As always, make sure you have backups!

Stop the service:

sudo service mysql stop

Ensure the service is no longer running:

sudo ps ax | grep mysql

If it is still running, give it some time:

sudo kill <pid>

But eventually, if it is still running, you have to kill it aggressively:

sudo kill -9 <pid>

Once you've confirmed it is no longer running, you can continue with the update.

After the update is completed, especially if you had to kill -9, be sure to run mysqlcheck to ensure that whatever may have caused the service to not stop is not a corrupted or broken table. Also ensure you have regular backups (and make sure those backups actually work!).

| improve this answer | |

In my case there was an issue with an existing /etc/mysql/my.cnf. Checking the error log in /var/log/mysql/error.log revealed:

150112  5:45:47 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
150112  5:45:47 [ERROR] Do you already have another mysqld server running on port: 3306 ?
150112  5:45:47 [ERROR] Aborting

150112  5:45:47  InnoDB: Starting shutdown...
150112  5:45:52  InnoDB: Shutdown completed; log sequence number 0 1883376705
150112  5:45:52 [Note] /usr/sbin/mysqld: Shutdown complete

Obviously there might be a different issue with the my.cnf, but in my case it was that we were trying to bind to an old IP address. Changing to:


fixed that and it start up no problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.