Backup and restore a MySQL database from a PHP script

comments 6
Labs

Last week a customer asked if it was possible to migrate her site to a different server. Unfortunately she was not able to get in touch with her webmaster anymore and all she could provide was the FTP access.

After some investigation I was able to find the database connection info in the site configuration script! Unfortunately, with no ability to remotely connect to the database (I could easily get the data with my database preferred tool: Navicat), no SSH access nor cPanel I had to write a script to save the database in a text file.

With the script the exported database can be easily downloaded and moved to the new server.

If anyone is facing the same issue you may like to download the script by clicking here.

In the download you will also find a “restore” script that can let you easily restore the database on the new server.

You fill find the instructions about how to use each script at the beginning of the script as a PHP comment.

6 Comments

  1. I downloaded the MySQL Migration Tools zip file several times but I think its corrupted.
    Please re-upload the script.

  2. This excellent website definitely has all of the info I wanted concerning this subject and didn’t know who to ask.

Leave a Reply