Backup and restore a MySQL database from a PHP script

comments 6

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.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.