Sunday, 14 June 2009

SQL dump with each database separately

Hi Readers,

This morning I missed my old MySQL tables from Windows XP, but for some reason I needed separate database dumps for each db. As far as I know I've 2 options to do that, dump each db in command line or to write a script in command line. No way. So I made a quick & dirty PHP script to generate the dump commands:

$usr = 'YOURUSER';
$pwd = 'YOURPASS';
$date = date('Ymd');

$conn = mysql_connect('localhost', $usr, $pwd);
$resource = mysql_list_dbs();

while ($row = mysql_fetch_object($resource)) {
echo 'mysqldump -u '.$usr.' --password='.$pwd.' '.$row->Database.' > mysqldump_'.$date.'_'.$row->Database.'.sql'."\n";

And then:
c:\php dumpscript.php > dumpcmd.bat

Thats it.


No comments:

Post a Comment

Note: only a member of this blog may post a comment.