Db's dumps in seperate files?

Discussion in 'General' started by skoena, Mar 5, 2013.

  1. skoena

    skoena Member

    How to get a dump of all db's in seprate files?

    I want to restore all db's on newly installed server.

    Can somebody give exact codes to get this done via commandline?
     
  2. tahunasky

    tahunasky New Member

    this is what i use.

    mysqldump dbispconfig -u {MYSQLUSER} -p {MYSQLPASSWORD} > /tmp/dbispconfig.sql

    replace {MYSQLUSER} with username and {MYSQLPASSWORD} with password.

    Just do the same command for each database.

    You can also do a dump/backup and restore from phpmyadmin, which is probably easier.
     
    Last edited: Mar 6, 2013
  3. Parsec

    Parsec New Member

    Or you could do them all at once if you have the root password for mysql

    Code:
    #!/bin/bash
    
    cd /var/backup
    for i in $(/usr/bin/mysql -uroot -p<your_root_password> -e 'show databases'|grep -v Database);
    
    do
    if ( test $i != information_schema )
    then
    /usr/bin/mysqldump -uroot -p<your_root_password> $i > ./$i.dump ;
    fi
    done
    
    The just go to /var/backup and grab them (this assumes you have a /var/backup dir - if not change it to something else in the script.
     

Share This Page