My computer froze and I forgot it was updating in the background so I restarted it. When I rebooted I tried to login (and if I entered the wrong password it said incorrect password), but then the screen would go blank for a second and then return to the login screen. I booted into recovery mode and ran the package recovery manager. That did the trick and allowed me to log back in. I ran sudo apt-get update and sudo apt-get install to make sure all packages were updated correctly. However, mysql is no longer working (I cannot turn the service on). When I try sudo apt-get install here is the error message:

2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.5 (5.5.43-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I also tried sudo apt-get -f install but got the same error message. My question is how do I fix the problem and get the database working again, with an abundance of caution to make sure that the the actual mysql databases/tables do not get deleted.


Following this answer I removed mysql and reinstalled.

sudo apt-get clean

sudo apt-get autoclean

sudo apt-get remove --purge mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5

sudo apt-get install mysql-server

The final step did not work (it installed, but at the end of installation it said root password was already set and database would not start). Instead of doing the final step in the terminal, I had webmin install mysql (which is how I originally set up the database) and the database would start and stop no problem. Except my database directory location is on a second hard drive at /media/D/mysql/, not at /var/lib/mysql and what was working was only a much older set of files that never got deleted from /var/lib/mysql when I copied them to the second hard drive.

Following these instructions, which I originally used to change the directory, I edited the relevant configuration files (obviously I did not copy the files over to the D drive as they're already there, I just edited the configuration files). After I change the database directory location the database will no longer start.

Here is what's in the error log (terminal just tells you it can't start):

50514 16:50:55 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
150514 16:50:55 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
150514 16:50:55 InnoDB: The InnoDB memory heap is disabled
150514 16:50:55 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150514 16:50:55 InnoDB: Compressed tables use zlib 1.2.8
150514 16:50:55 InnoDB: Using Linux native AIO
150514 16:50:55 InnoDB: Initializing buffer pool, size = 128.0M
150514 16:50:55 InnoDB: Completed initialization of buffer pool
150514 16:50:55 InnoDB: highest supported file format is Barracuda.
150514 16:50:55  InnoDB: Waiting for the background threads to start
150514 16:50:56 InnoDB: 5.5.43 started; log sequence number 1595675
150514 16:50:56 [Note] Server hostname (bind-address): ''; port: 3306
150514 16:50:56 [Note]   - '' resolves to '';
150514 16:50:56 [Note] Server socket created on IP: ''.
150514 16:50:56 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

I researched the errorTable 'mysql.host' doesn't exist and found this answer, I tried to make sure mysql had permissions (see below), but that did not work.

chown -R mysql /media/D/mysql
chgrp -R mysql /media/D/mysql

One suggestion was to see the output of mysqld, it yields the following error in the terminal:

150514 17:00:55 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150514 17:00:55 [Note] mysqld (mysqld 5.5.43-0ubuntu0.14.04.1) starting as process 11565 ...
150514 17:00:55 [Warning] Can't create test file /media/D/mysql/computername.lower-test
150514 17:00:55 [Warning] Can't create test file /media/D/mysql/computername.lower-test
mysqld: Can't change dir to '/media/D/mysql/' (Errcode: 13)
150514 17:00:55 [ERROR] Aborting

150514 17:00:55 [Note] mysqld: Shutdown complete

Update 2

I changed the mysql configuration /etc/mysql/my.cnf and it uses key_buffer_size correctly now and mysqld will start no problem. sudo mysql start , however, yields the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


So stupid! Actual location of the files is /media/D_/mysql not /media/D/mysql. And then when I figured that out I also had to remember to make the change in the AppArmor profile as well. It would be so much easier if the error message said the directory does not exist!!!!

  • If you want to be sure not to lose your databases, make a backup of /var/lib/mysql (that's the default location anyway)
    – Brian
    May 14, 2015 at 21:44
  • Try just service mysql start; see if it reports errors to the console. If there aren't errors at the console, check for errors in the logs under /var/log/.
    – sarnold
    May 14, 2015 at 22:13
  • @sarnold I've pasted in the error log above.
    – Michael
    May 15, 2015 at 3:08

1 Answer 1


Make sure your my.cnf doesn't have any options that have been deprecated. I had a similar problem because I had default-character-set listed under [mysqld], but in the newer version of mysql this had been renamed to character_set_server. However, mysql very unhelpfully let me know of this by simply hanging when trying to start the service. And the package manager will generally try to stop and/or start the service when installing a new version.

To check, try running mysqld by itself. If there are config problems, it should say so and die immediately.

  • mysqld will now run fine, but I cannot get mysql running.
    – Michael
    May 15, 2015 at 17:32

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.