Issue
Generally you would use phpMyAdmin within the Plesk Control Panel to perform a backup of your MySQL database ( Exporting and importing a MySQL database ) but sometimes this process can fail or time out if you have a reasonably large database. The work around for this is to use a simple PHP script to invoke a mysql dump command and place the resulting backup file into your private directory within your FTP area for download.
Solution
Create the following PHP file either directly from the Plesk File
Manager or on your local computer and then upload it to the httpdocs
directory. You could call it mysqldump.php
Copy the following line into your PHP file:
Replace YOURUSERNAME with your database username, YOURPASSWORD with your database password (note that you do NOT put a space between -p and YOURPASSWORD) and YOURDATABASENAME with your database name and specify a custom backup filename if you wish.
Now run the command by visiting the mysqldump.php URL in your browser. e.g. http://www.domain.co.nz/mysqldump.php
- Be aware that it may take a moment to backup the database, so please
ensure you only visit the URL once and allow it to complete.
You should now have the resulting backup file ready for download via FTP in your private directory. Note that any files within your private directory contribute to your overall disk quota so remember to remove the file once you have downloaded the backup. Best practice would be to also delete the mysqldump.php file from your
hosting account because it contains your database login credentials and also to avoid any accidental execution in future.