I did a very foolish thing... I did not realize installing mariaDB would uninstall MYSQL 5.7 using apt-get. (Using Ubuntu 16.04).

So now I am trying to recover my data.

So far, I have read many guides and tried several things. I think this has gotten me into bad position, because the advice seems to be very version specific.

My most successful attempt is 1) Fresh install of MaraiDB. 2) copy * files from old sql directory to new. 3) Copy database directory myDatabase/ from old sql directory to new. 3) Run mysql_secure_installation 4) Configure my users, etc. etc.

This works except that I cannot run sql queries.

SELECT * FROM myDatabase.tableOne;

I get either:

SQL Error [1932] [42S02]: (conn:56) Table 'myDatabase.tableOne' doesn't exist in engine


SQL Error [1146] [42S02]: (conn:56) Table 'myDatabase.tableTwos' 

It seems that all tables give one of these two errors.

So far, I have read that mysqlcheck can fix this.

If I run

/var/lib/mysql$ mysqlcheck myDatabase
Error    : Table 'myDatabase.tableOne' doesn't exist in engine
status   : Operation failed

I can't find any suggested solutions for fixing this. Although perhaps I went the wrong way from the beginning. Thanks for your help.

2 Answers 2


Before doing anything else I would recommend that you backup the old mysql data directory and the configuration file on /etc. So should something go wrong you don't loose your data.

Then I would check what specific MariaDB version of you have installed. As per MariaDB compatibility chart, you need MariaDB 10.2 to migrate from MySQL 5.7. Once you are sure you have the right version installed, you should refer to the migration doc:


Alternatively you could uninstall MariaDB and install MySQL again, just check that you are installing the latest 5.7 version available. For this you can download a deb package from the mysql downloads and install it manually or set up the mysql repository: https://dev.mysql.com/downloads/repo/apt/


error is showing that, You are using old ibdata file. I would recommend, uninstall mariadb and install mysql back. Then take healthy backup.

And do fresh installation of mariadb and restore backed up data.

  • it might be a good idea to create a backup of the entire machine prior to doing any of this. In my experience, uninstalls of mysql-based products can sometimes remove the data files, too, which might be bad if you don't have a backup.
    – Hannah Vernon
    Oct 19, 2020 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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