1

My server hard disk crashed and unfortunately my MySQL backup (which occurs once a day) was missing some important data, but I have the files from the folder /var/lib/mysql.

On my new installation on Ubuntu 16.4, I installed MySQL successfully and attempted to copy the files from the old /var/lib/mysql to the new installation, however I encountered issues and decided to reinstall MySQL.

I've followed these instructions to fully uninstall and reinstall MySQL, however now when I try to install MySQL I see this output:

user@computer:~$ sudo apt-get install mysql-server mysql-client
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following NEW packages will be installed
      mysql-client mysql-server
    0 to upgrade, 2 to newly install, 0 to remove and 0 not to upgrade.
    Need to get 0 B/20.2 kB of archives.
    After this operation, 317 kB of additional disk space will be used.
    Selecting previously unselected package mysql-client.
    (Reading database ... 213412 files and directories currently installed.)
    Preparing to unpack .../mysql-client_5.7.12-0ubuntu1_all.deb ...
    Unpacking mysql-client (5.7.12-0ubuntu1) ...
    Selecting previously unselected package mysql-server.
    Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
    Unpacking mysql-server (5.7.12-0ubuntu1) ...
    Setting up mysql-client (5.7.12-0ubuntu1) ...
    Setting up mysql-server (5.7.12-0ubuntu1) ...

However:

  • No prompt comes up of any kind, asking about database configuration OR setting a password for the MySQL root user
  • No /etc/mysql/ folder is created
  • No /var/lib/mysql/ folder is created

When trying to uninstall mysql-common, I see the following error:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 mysql-client : Depends: mysql-client-5.7 but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

How can I install MySQL correctly again with the prompts and correct folders, or how can I find the default /etc/mysql/ and /var/lib/mysql/ folder content to manually set it up?

  • Install mysql-common. That package will create the /etc/mysql folder, probably also /var/lib/mysql once you have the server running. – Jos May 11 '16 at 8:48
  • Thanks @Jos. I can't uninstall mysql-common - I've added the output to apt-get purge mysql-common to the original question. – Ben May 11 '16 at 8:51
  • Hard to tell how to go from here - perhaps try to reinstall mysql-client, then install dbconfig-mysql, then uninstall mysql-client and mysql-common. Do you have any held packages in that area? (do dpkg -l | grep ^h). – Jos May 11 '16 at 8:57
  • dpkg -l | grep ^h outputs nothing at all. If I try to remove mysql-common with mysql-client installed, the unmet dependency is dbconfig-mysql. If I try to remove it without mysql-client installed, the unmet dependency is mysql-client. If I try to install dbconfig-mysql, it says that it is already the newest version. – Ben May 11 '16 at 9:01
  • 1
    @Jos - I've just solved it! While trying to uninstall said that the dbconfig-mysql dependency was unmet, purging dbconfig-mysql actually removed the whole lot and I was able to reinstall and it's working! Thank you for pointing me in the right direction. – Ben May 11 '16 at 9:06
1

The following commands worked for me to uninstall and reinstall MySQL (in this order, although I don't know if some of these commands are surplus):

  • sudo apt-get install mysql-client
  • sudo apt-get install mysql-server
  • sudo apt-get purge dbconfig-mysql
  • sudo apt-get purge mysql-common
  • sudo apt-get install mysql-server
  • sudo apt-get install mysql-client

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.