We want to delete/remove the Magento table prefix.

How can this be done? Is there a script available to do this in one-go?

Essentialy changing the table myprefix_catalog_category to catalog_category

We have had the prefix since 1.3 - but it is causing us too much problems when running scripts or extensions where one forgot to respect it. Removing it seems a lot more logical then.

  • what do your mean by "remove table prefix"? You have tabels like "mg_catalog_...." and you want them to be "catalog_...."?
    – Marius
    Commented Jul 16, 2015 at 10:57
  • I thought it was important to add this. See my answer and add to it if you find necessary
    – snh_nl
    Commented Jul 16, 2015 at 10:59
  • This is not really magento related. it's a db related question.
    – Marius
    Commented Jul 16, 2015 at 11:00
  • Following Link could be helpful: - dba.stackexchange.com/questions/13259/… Commented Jul 16, 2015 at 11:38

2 Answers 2



  • Make a database backup
  • Disable caching
  • Save this file on your server (download here)
  • Edit settings in the file
  • Run the file in dryrun modus first (upload and run from browser)
  • If you are satisfied: change dryrun to false and run again
  • All done!
  • Go to app/etc/local.xml and modify the table prefix (to empty)

Don't forget to reset opcache and reset all caches before it will work.

  • Enable caching afterwards

You're done.

UPDATE. Script can be updated to support rename


In phpMyAdmin select all tables, then With Selected.. -> Replace table prefix would surely be quicker than an export and re-imports.

Then edit your local.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.