When you need to take a backup of a large MySql database, then “mysqldump” command come most handy and does the task in few seconds. But for that we need to access the web server or database through SSH. And database access in 99% cases is not allowed from remote location for security reasons.
I found myself in such situation recently and PhpMyAdmin export feature was not working due to script timeout or memory issues. So I googled for this and after 15-20 minutes of searching I found this very useful and working small script for the job.
$User = ""; // Put New user -- CPanel user or MySQL user with All permissions is fine.
$Password = ""; // Put New Password
$DatabaseName = ""; // Put Database name
$File = ""; // Put the complete path here -- /home/user/database.sql for example
$Results = shell_exec( "mysqldump --allow-keywords --opt -u$User -p$Password $DatabaseName > $File");
Just upload the file on the web server and execute it. Do remember to specify the path of the file so that it is accessible from the web e.g. provide any path which is inside public_html or www folder on most servers.
It will take just few seconds for 300-400MB database and then you can download the file and use it as you like.
Search the site
Random Testimonial
- ~ Elance ID – catchlight
"This was a seemingly small job, but a very important one and one that needed to be done right. A certain level of knoowledge is required for this type of task and nirvaat carried it out beautyifully. Nice work and I'd reccommend this provider to anyone working with" - Read more testimonials »
What's the little bird saying?
- Do u have an image and need a color scheme for your website around it. This is what u are looking for: http://www.degraeve.com/color-palette 2010-08-01
- Design a color scheme for your websites at: http://colorschemedesigner.com/ 2010-08-01
- New blog post: MySql Dump Using a PHP Script http://www.nirvaat.com/blog/web-development/mysql-dump-using-php-script/ 2010-07-25
- @pavanagrawal If computers will start asking questions then who will answer it!!!!! we have to creat a human version of google! in reply to pavanagrawal 2010-07-17
- Turn a USB Flash Drive Into Extra Virtual RAM [USB Drive] http://bit.ly/cb9fOT 2010-06-28
- More updates...
Posting tweet...

July 25, 2010 in