Cryptic MySQL Error 1025 on Drop of Foreign Key

Mysql_manager_logo

Over the years, we have inherited a number of databases, most utilizing MySQL.  Modifying those tables can lead to some odd situations, receiving errors that we shouldn’t, and usually with MySQL, receiving cryptic errors.  One recent database upgrade had us scratching our heads for a few minutes –

This database had foreign keys using the format ‘fk_keyName’.  All of those indexes had foreign keys, and we had upgraded numerous other tables in this database, dropping some foreign keys and replacing them with an optimized schema.  However, upon dropping one particular foreign key, we received the following error:

General error: 1025 error on rename of ‘.\databaseName\tableName’ to ‘.\databaseName\#sql2-aaa-aaa’ (errno:152)

After double-checking the index name and confirming it was correct, we ran ‘SHOW CREATE TABLE’, and noticed that although this foreign key was an index, it did not have a foreign key constraint associated with it.  So in this one instance, the foreign key was only an index, most likely a mistake by the original authors.

Hopefully, this will save just a few minutes for someone out there, or save us a few minutes if/when we run into the situation again.

Read More

Very slow PHP with XAMPP on Windows

We use XAMPP on a few machines to quickly test some PHP scripts. Upon upgrading to the latest version of XAMPP, everything slowed to a halt. It turns out that the database connection was slowing down the scripts in phpMyAdmin, and our custom scripts. We just added a line to our phpMyAdmin config.inc.php, and adjusted the database connection strings in our custom scripts to fix things.

The line in config.inc.php:

$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;

Our custom scripts were fixed by using 127.0.0.1 instead of localhost.

(On a side note, we had already changed our hosts file & ruled that out as a problem prior to changing these values.)

Great thanks to EllisLab for the phpMyAdmin tip.

Read More