DataBase Error InnoDB: cannot calculate statistics for table - mysql

While checking the error logs in my wordpress site I would get the following for the mysql logs.
161120 6:41:58 InnoDB: cannot calculate statistics for table databasename/wp_wfHoover
InnoDB: because the .ibd file is missing. For help, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
161120 6:41:58 [ERROR] MySQL is trying to open a table handle but the .ibd file for
table databasename/wp_wfHoover does not exist.
Have you deleted the .ibd file from the database directory under
the MySQL datadir, or have you used DISCARD TABLESPACE?
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
What is the problem here? My site is hosted on an ubuntu server using apache2.Thanks in advance

Related

Recovering MySQL Database From Data Directories

I am trying to recover a MySQL database from data directories. I do have a backup, but it is a week old and I would prefer not to use it.
I have transferred all of the files to a fresh MySQL installation and have given them 777 permissions along with directory and group ownership to mysql.
When I try to start, I get the following two errors:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 0 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
and
170110 16:42:58 [ERROR] Plugin 'InnoDB' init function returned error.
170110 16:42:58 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
For the first error, I have tried specifying the log file size in the my.cnf and also as an argument to mysqld. I keep getting the same error message.
For the second error, I have tried deleting the ib_logfile0 and ib_logfile1, but if I do, I get a bunch of nonsensical characters when starting mysqld followed by
/usr/sbin/mysqld(+0x286668)[0x7f65298d4668]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
How can I retrieve the data in this database?

Can't create a table in MySQL because "it already exists"

I am having an issue with MySQL, relating to my previous question.
I recently needed to remove a table from MySQL, and now need to create a new one in its place. I am having a hard time with this because, as MySQL Workbench says, "The table already exists." Since the error from MySQL Workbench is not particularly helpful, here's some stuff that I pulled out of my error log. What's the problem?
I am running MySQL 5.7 on Windows 8.1 Pro x64.
2014-03-06T01:38:55.459658Z 0 [ERROR] InnoDB: Table thepwf_prgminteractions/p2p_messagedata in the InnoDB data dictionary has tablespace id 25, but tablespace with that id or name does not exist. Have you deleted or moved .ibd files? This may also be a table created with CREATE TEMPORARY TABLE whose .ibd and .frm files MySQL automatically removed, but the table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
2014-03-06T01:38:55.464671Z 0 [ERROR] InnoDB: Table thepwf_prgminteractions/p2p_onlineusers in the InnoDB data dictionary has tablespace id 26, but tablespace with that id or name does not exist. Have you deleted or moved .ibd files? This may also be a table created with CREATE TEMPORARY TABLE whose .ibd and .frm files MySQL automatically removed, but the table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
2014-03-06T01:38:55.468672Z 0 [ERROR] InnoDB: Table thepwf_prgminteractions/p2pchat_betaaccesskeys in the InnoDB data dictionary has tablespace id 24, but tablespace with that id or name does not exist. Have you deleted or moved .ibd files? This may also be a table created with CREATE TEMPORARY TABLE whose .ibd and .frm files MySQL automatically removed, but the table still exists in the InnoDB internal data dictionary.
As the table exists then just remove it with drop table (http://dev.mysql.com/doc/refman/5.6/en/drop-table.html)
i.e.
drop table <table name>
You must have done something wrong as the table still exists.
Can check this with select
i.e.
select * from <table name>
It looks your innodb tablespace has been corrupted.
Checkout this post from percona
http://www.mysqlperformanceblog.com/2008/07/04/recovering-innodb-table-corruption/
And these tools
http://www.percona.com/software/percona-toolkit
They will save you!
Well I don't know how well they run on windows but what the tools do should be about the same.
Go to where your mysql folder is installed:
C:\Apps\mysql-5.6.25-win64\data\databasename
Under databasename you will find your tablename. Delete this table manually and create it again using SQL Create Table command.

XAMPP: MYSQL stops working after I restart

I am having problems with starting MYSQL in XAMPP. Apache starts alright but then MYSQL keeps reporting an unexpected shutdown.
I was led to delete C:\xampp\mysql\data\ibdata1 and it works after that but that deletes all my databases and MYSQL stops working again after I restart my machine.
I went through the error logs and this is what I saw:
[ERROR] InnoDB: Attempted to open a previously opened tablespace.
Previous tablespace mysql/innodb_index_stats uses space ID: 2 at
filepath: .\mysql\innodb_index_stats.ibd. Cannot open tablespace
yiicrud/customer which uses space ID: 2 at filepath:
.\yiicrud\customer.ibd InnoDB: Error: could not open single-table
tablespace file .\yiicrud\customer.ibd InnoDB: We do not continue the
crash recovery, because the table may become InnoDB: corrupt if we
cannot apply the log records in the InnoDB log to it. InnoDB: To fix
the problem and start mysqld: InnoDB: 1) If there is a permission
problem in the file and mysqld cannot InnoDB: open the file, you
should modify the permissions. InnoDB: 2) If the table is not needed,
or you can restore it from a backup, InnoDB: then you can remove the
.ibd file, and InnoDB will do a normal InnoDB: crash recovery and
ignore that table. InnoDB: 3) If the file system or the disk is
broken, and you cannot remove InnoDB: the .ibd file, you can set
innodb_force_recovery > 0 in my.cnf InnoDB: and force InnoDB to
continue crash recovery here.
Adding this line in my.cnf worked for me:
innodb_force_recovery = 1
There is a solution on this page: XAMPP/MySQL: could not open single-table tablespace file .\mysql\innodb_index_stats.ibd after restart of MySQL
Move (DON'T DELETE) those files, into another folder:
innodb_index_stats.frm <br>
innodb_table_stats.frm <br>
slave_worker_info.frm <br>
slave_master_info.frm <br>
slave_relay_log_info.frm <br>
and .ibd files with the same filename.
Try start MySQL.
Thanks a lot everyone.
I have able to solve it. It appears the database was created in a later version and was incompatible with this new version of xampp so i created the databases again and imported the tables into them. Previously I was importing the database with the create statements as well.
Had the idea from Salman's comment.
Try this
rename the XAMMP\mysql\data folder to any other name you wish (say data_old )
make a new folder in XAMMP\mysql name data and copy all the files in it including ibdata1
close all running programs and restart XAMPP
No need to copy files from data_old but if you do have previously constructed databases then you may copy some files from data_old.
The solution may come again. If it then you have to change the port to something else like 3308 in the config settings as well as in phpMyAdmin/config.inc.php.
If the problem stays still then its better to change the application which uses the port 3306 and set default settings in XAMPP.

copying raw mysql data from on server to another

I'm trying to clone raw data from all databases on a MySQL instance in Live to a test environment. The network guys have told me the data has been synched and copied across but I can't start the MySQL instance in the test environment. I'm using the innodb engine and I can see the ibdata1 file, mysql-bin files and ib_logfiles copied over along with the relevant db folders.
The error I'm getting in the error log looks like the following:
130911 13:53:08 InnoDB: Error: table <table-name>
InnoDB: in InnoDB data dictionary has tablespace id <id>,
InnoDB: but tablespace with that id or name does not exist. Have
InnoDB: you deleted or moved .ibd files?
The cloning process doesn't stop the Live MySQL instance and I'm wondering is this the problem. I don't want to use mysqldump or another backup tool. I just want to copy the raw data across. Thanks for any advice.
You can't hot-copy these files and expect them to magically work.
You can use the innobackupex tool to create a stable snapshot. This will take care of adjusting the files as necessary to be consistent and complete.

Cannot start MySql server

I have problem starting the MySql server.
The log says:
InnoDB: Error in opening ./ibdata1
111220 16:16:43 InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.0/en/operating-system-error-codes.html
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
/usr/libexec/mysqld: Disk is full writing './mysql-bin.000028' (Errcode: 28). Waiting for someone to free space... Retry
in 60 secs
After I check the disk - it says it's full.
So, after searching for solution - I found that I need to purge the binary log.
However, in order to purge - I need to start the MySql server, but all the spacein the disk is taken by the binary log, so I can't start...
It's also not advised to simply delete the binary logs.
So, I am kind of stuck.
Can't run the mysql to purge logs and can't purge logs because can't run server.
Any help? :)
Edit: The disk contains only the logs, there's nothing else.
If the disk is ext[2|3|4] you can use tune2fs to set the portion of the disk reserved for root to 0, giving you maybe enough breathing room to start the server
this would be tune2fs -m 0 /dev/whatever (after unmounting, ofcourse)
Try to start the mysql server with the option --expire_logs_days=, it should delete the log and older than days directory at startup.
bye
Gianluca