Mysql InnoDB Error code #1025 - mysql

We are using Mysql 5.1 in our production servers and trying to run an alter query to change the datatype of a column from tinytext to varchar(200). On running the alter query we are seeing this error :-
#1025 - Error on rename of './msging/#sql-123b_ab7634' to
'./msging/outboxes' (errno: -1)
The MySql forums suggest that this error might be because of foreign key constraints. But our schema does not have any foreign keys. The mysql error logs are showing the below mentioned error.We went through the link mentioned in the error statement but couldn't find anything useful. Any ideas what might be going wrong ?
InnoDB: Error: './msging/outboxes.ibd' is already in tablespace memory
cache 111001 12:40:18 InnoDB: Error in table rename, cannot
rename msging.#sql-123b_ab4828 to msging.outboxes 111001
12:40:18 InnoDB: Error: table msging.outboxes does not exist in
the InnoDB internal InnoDB: data dictionary though MySQL is
trying to drop it. InnoDB: Have you copied the .frm file of the
table to the InnoDB: MySQL database directory from another
database? InnoDB: You can look for further help from InnoDB:
http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html

When you rename a table using ALTER TABLE, here's what happens:
The table is copied to a new file with a random filename.
Changes are made to the new file.
The old table is renamed using a random temporary filename.
The new table is renamed to take the place of the old file.
The old table is removed.
See this link for more details: http://www.xaprb.com/blog/2006/08/22/mysqls-error-1025-explained/
You can use innotop to get more details on the error: http://code.google.com/p/innotop/

Related

DataBase Error InnoDB: cannot calculate statistics for table

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

MySQL InnoDB Error 1034 Incorrect key file for table 'tableName'; try to repair it

I'm using InnoDB engine for MySQL and file_per_table setting is set, suddenly two of the .ibd files got corrupted and their size became zero Byte, now I managed to recover old version of these two .ibd files and I do these steps to recover my data
1- create an empty database
2- create a table the same as corrupted one
3- use "ALTER TABLE tableName DISCARD TABLESPACE"
4- copy the recoverd .ibd file in the data folder
5- use "ALTER TABLE tableName IMPORT TABLESPACE"
but it gives me this error
Error (1034): Incorrect key file for table 'tableName'; try to repair it
and when I try to repair it using REPAIR TABLE tableName;or even with
mysqlcheck -r -u root -p databaseName
`it gives me this error
The storage engine for table does not support repair
You took wrong approach to recover the table. The file's size became zero because of file system inconsistencies.
You don't need the ibd file, you need the data in it. So recover the data, not the file.
As we discussed you should scan the disk with page_parser and then extract records from InnoDB pages (constraints_parser from same toolkit).

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.

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.

How to restore Innodb database?

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).