How to back up MYSQL database with PHP.

Leave a Comment
Have you ever wondered how you can back up your MYSQL database in PHP?

This function helps you create a back up file for your MYSQL database. Define the following constants in your config file.

define ('DATABASE_NAME','YOUR DATABASE NAME'); define ('DATABASE_USER','DATABASE USERNAME'); define ('DATABASE_PASSWORD','DATABASE PASSWORD'); define ('DATABASE_HOST','DATABASE HOST');
Call the backUpDb() function and pass the above parameters appropriately. To select all the tables in the database just pass the *  value for the $tables parameter.

backUpDb(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD,DATABASE_NAME);

After executing the above method your database will be backed up and saved on the project folder with the current time stamp.

Below is the full git hosted in Github.



0 comments:

Post a Comment