How to restore Innodb database? - mysql

I physically moved the database and now I am not able to restore Innodb database.
I am getting this error-
140131 13:03:41 [ERROR] Cannot find or open table table_t1/t1#P#p0 from
the internal data dictionary of InnoDB though the .frm file for the
table exists. Maybe you have deleted and recreated InnoDB data
files but have forgotten to delete the corresponding .frm files
of InnoDB tables, or you have moved .frm files to another database?
or, the table contains indexes that this version of the engine
doesn't support.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
how you can resolve the problem.
Help me to restore this db

Put it back and move it through the SQL interface (e.g. RENAME TABLE).

Related

MySql server logs error after installation

I have installed MySql fresh installation version 5.17.9
Mysql services started nicely and giving good throughput
But in server logs, I got this type of error:
InnoDB: Cannot open table mysql/engine_cost from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/help_category from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/help_keyword from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/help_relation from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/help_topic from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/innodb_index_stats from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/innodb_table_stats from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/server_cost from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/servers from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/time_zone from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/time_zone_leap_second from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/time_zone_name from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/time_zone_transition from the internal data dictionary of InnoDB though the .frm file for the table exists.
Cannot open table mysql/time_zone_transition_type from the internal data dictionary of InnoDB though the .frm file for the table exists.
Please help me how to fix such issues without restoring database from dump?
As you said its a fresh install, but it doesn't look so.. maybe the cause is not known :P
Solution is to delete those .frm files manually (they are often called orphan files).
For more info..
see this link
and this answer too

When myd files will be created in MYSQL?

I am facing an issue which is,
java.sql.SQLException: Can't create/write to file 'xxxxx.MYD' (Errcode: 13)
But it has already executed some Alter queries.
My Question is, This error occurs because of permission(which is not enough to write a file), then how the another queries has executed?
.MYD is data file in myisam ENGINE tables as myisam tables contains 3 kind of files.
.frm : schema definition
.myd : data
.myi : index
First of all check if that is myisam file on which you execute alter and other updation at the time of this error or innodb.
Are u still getting this error or it was temporary at that time.
mysql has permission on your data directory as well /tmp partition.

Restoring MySQL Databases when reinstalling Wamp

I am attempting to restore my old databases to a new Wamp installation. However, I did not take a backup of Mysql files before I did this. Thankfully the uninstallation has not deleted all the files, but in my data folder I have :
1) All the databases (As folders)
2) auto.cnf
There are no ib* files in the old folder. Is it still possible to restore my databases somehow?
I have tried to replace the entire mysql5.6.17 folder (there has been no change of version between the installations), but Wamp remains orange and never turns green.
If I replace only the data folder, the MySQL service starts, I can see the databases, but not the tables.
If I change the path in my.ini to point to the old wamp's data folder, I cannot see the old databases at all.
EDIT : Was experimenting a bit, copying the database folders directly into the new Wamp's data folder allows me to get a list of all the tables properly, but there is no actual data in the tables, and trying to query it using MySQLWorkbench gives me the error :
Error Code: 1146. Table 'testdb.users' doesn't exist
EDIT 2 : Found this in the error log file in my data folder :
2014-08-03 06:24:46 25164 [Warning] InnoDB: Cannot open table testdb/users from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
As I thought, its a problem with InnoDB's own mapping. Is there a way to resolve this manually?
If you created an INNODB database, and made no other config changes to store the actual data in seperate table spaces then all the actual data for that INNODB databases will have been stored in the \wamp\bin\mysql\mysql5.6.17\ibdata1 file.
If you do not have that file from the old install then your data is lost.
There will also be info in a \wamp\bin\mysql\mysql5.6.17\data\DATA_BASE_NAME\ folder, one .frm file for each table that was in the database, but this is basically just schema information and not actual data.
For future reference, InnoDB Backup and Recovery
GOLDEN RULE:
Always backup database (from phpmyadmin) before major changes.. better to spend 1 minute for that, than going into trouble..
How to Copy data folder
If you want to copy the database, then INSTALLATION/mysql versions should be same.. then rename newly installed data folder to i.e. data_my_old,so now there you can place the backuped data folder (it should contain ibdata1 file).
Depends on innodb_file_per_table setting.
If it was OFF then all your tables were in ibdata1. Now you have quite new ibdata1 (since you see errors "Cannot open table testdb/users from the internal data dictionary", that means InnoDB runs fresh new dictionary). That means that now the data is somewhere on the disk. The recovery is quite difficult and requires a lot of tedious work. You need to take an image of the disk, scan it with stream_parser to find InnoDB pages, then recover the InnoDB dictionary, then find index_id of every table and if the stream_parser has found this index run c_parser to extract records from the index.
If innodb_file_per_table was ON and you do see .ibd files in the databases directories then recovery is much easier. First, you may try to reconnect individual ibd files with ibdconnect or extract records from the ibd files with stream_parser/c_parser.
The mentioned tools are part of TwinDB data recovery toolkit
i have just done a google search and found this....
Go to C:\wamp\bin\mysql\mysql5.5.24\data
Find a file called "mysql-bin.index"
Rename that file to "mysql-bin.index-corrupt"
Restart the server and it will work fine, all your database will be where you left them.

MYSQL5.5 INNODB optimazation

looking to optimize mysql5.5 databases for INNODB. I have tried the link
Note: The databases also contains MYISAM tables.
Howto: Clean a mysql InnoDB storage engine?
As per the instructions I have dropped all databases as well as ibdata* and ib_logfile* and made changes in my.cnf like
[mysqld]
innodb_file_per_table
innodb_flush_method=O_DIRECT
innodb_log_file_size=1G
innodb_buffer_pool_size=4G
Now on restoring the backup, not only mysql storing INNODB tables in separate files, but it is doing it for MYISAM tables as well.
This is resulting in MYISAM database unusable.
when I am trying to access the website having MYISAM tables I am getting the error - Error displaying the error page: Application Instantiation Error
Can't makeout why mysql is storing MYISAM tables in separate files.
Thanks.
AFAIK MyISAM always stores tables in their own files (3 files per table: .MYI, .MYD and .frm).
It is not allowed to remove the ibdata file. Do you have a backup of that file? To move from single file to file per table you need to do as stated here: http://dev.mysql.com/doc/refman/5.0/en/innodb-multiple-tablespaces.html (see under "Enabling and Disabling Multiple Tablespaces")

innodb Mysql database keeps getting tables damaged

Somehow, using MAMP PRO in my macbook certain two tables just disappear after a while. This has just started a couple of weeks a go and I can't find why. I read the logs and it points me to the INNODB troubleshooting the website tells this error
[ERROR] Cannot find or open table dbcobros/seguimiento from the
internal data dictionary of InnoDB though the .frm file for the table
exists. Maybe you have deleted and recreated InnoDB data
files but have forgotten to delete the corresponding .frm files of
InnoDB tables, or you have moved .frm files to another database? or,
the table contains indexes that this version of the engine doesn't
support.
is an example of out-of-sync data dictionary. I followed the advice and deleted the .frm orphaned file but I still couldn't recreate the table, so I deleted the database and created one again, and run an SQL dump I had. After a couple of minutes it happened again!
How this happened? How can I re-sync the data dictionary? Is this a problem with the mysql installation of the MAMP? I'm about to go into production with my application but now with this error I'm not sure if it will replicate in the production servers and they will lose critical data. Please help!