Error 1025 (HY000): Error on rename of to

Source: Internet
Author: User

Just another accidentally, on the slave to change the database schema, the result is the server in the Mmm_control state becomes: Replication_fail. The same operation was performed first through the writer to ensure that the server was running properly, and then the slave was considered to be pulled back to the Mysql-mmm camp.

After looking at the incremental SQL file that was executed, the main actions are: Add three fields to a table a A1, A2, A3, add a new table B, add a field for Table C C1, where C1 is a foreign key CF1 (the key point is: The name of the foreign key and the name of the field are the same, assuming that all are C1 ), the primary key B1 of the associated B. So the next thing to do is roll back these operations:

1, delete the new three fields in table A:

ALTER TABLE A DROP COLUMN A1;
ALTER TABLE A DROP COLUMN A2;
ALTER TABLE A DROP COLUMN A3;
2, delete the foreign key CF1 in the C table, and then delete the C1:

ALTER TABLE C DROP FOREIGN C1;
Executing this statement gets the following error message:

Error 1025 (HY000): Error on Rename of './db1/c './db1/#sql2 -31ef-2c2d4e ' (errno:152)

Then delete the field directly C1:

ALTER TABLE C DROP COLUMN C1;
The error message you get is:
Error 1025 (HY000): Error on Rename of './db1/#sql -31ef_2c2d4e ' to './db1/c ' (errno:150)

The reason for the problem is that the foreign key and the field use the same name.

Workaround:

1, first through

Show CREATE TABLE C;
Locate the statement that created the foreign key:

CONSTRAINT ' c_ibfk_2 ' FOREIGN KEY (' C1 ') REFERENCES ' B ' (' B1 ') on the DELETE SET NULL on UPDATE CASCADE
2, delete the foreign key by constraint name:

ALTER TABLE C DROP FOREIGN KEY c_ibfk_2;
You can then perform other subsequent operations.


Solve the above problem, through the "Start SLAVE" Restart SLAVE thread, after a while to check the status of Mmm_control, found that SLAVE has come back.


Resources:

Http://dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.