Mysql – Recovering MYSQL databases

ibdataMySQLrecovery

I needed to reinstall the WAMP server on Windows and in the process it reinstalled MYSQL as well. Now when I login to phpmyadmin, I can see my databases with the tables listed on the left side navigation panel. But when I click on the individual tables, it throws an error saying that the table doesn't exist. Browsing to this location C:\wamp\bin\mysql\mysql5.6.12\data, I see the folders with the database names. I also see files ending with *.ibd. The filenames are the same as the table names. With different databases, the folder contents are different. Some have files ending with *.ibd only. Some have a mix of *.ibd and *.frm. There is also a *.opt file in some folders. I do not know much about the admin side of MySQL. I only know enough to use PHP to interact with it for simple SQL statements. I have gone through some posts on how to possibly recovering the databases. But most of what was discussed there doesn't seem to either directly relate to my specific issue or are beyond my understanding.

Is there a simple enough way to restore the databases that is easy for anyone to follow? Or does it require previous experience with recovering databases?
Please suggest a few options.

Best Answer

A couple of possibilities, not sure if any of them will help you

Force recovery

[mysqld]
innodb_force_recovery = 4

If you run Force Recovery, your database will still be in an incoherent state. This will however allow you to make a backup of the data that you do have access to.

Usually, most of the data obtained in this way is intact. Serious corruption might cause SELECT * FROM tbl_name statements or InnoDB background operations to crash or assert, or even cause InnoDB roll-forward recovery to crash. In such cases, use the innodb_force_recovery option to force the InnoDB storage engine to start up while preventing background operations from running, so that you can dump your tables

Force InnoDB recovery

Permissions

Make sure the MySQL service user has full permissions on C:\wamp\bin\mysql\mysql5.6.12\data

enter image description here

The service that runs MySQL needs full control for the directory where you are storing your data files

Update

FS error

Problems reading from the C:\wamp\bin\mysql\mysql5.6.12\data directory ?

If you go to Control Panels-> Administrative Tools-> Events Viewer, then Windows Logs -> System, you might find more information about disk issues

One possible solution, would be to copy your data directory to another drive and/or directory.

Stop MySQL

Copy the data directory contents to the new drive and/or directory.

Open the C:\wamp\bin\mysql\mysql5.6.12\my.cnf file and change the datadir option under mysqld

[mysqld]

datadir=D:\some\other\directory

Start MySQL