MySQL DB Backup

How to take database backup in linux using command line sudo mysqldump -u root -p sq_offers > /var/www/sq_offers.sql
mysqldump is not a MySQL command, it is a command line utility. We must call it from our shell command line.
mysqldump -u username -ppassword databasename > backup.sql

3 Responses to MySQL DB Backup

  1. Praful Kumar says:

    mysqldump –opt -h $dbhost -u $dbuser –password='$dbpass' $dbname | gzip > $backup_file";

  2. prafulkr says:

    Through Script:

    $backup_file = $_SERVER['DOCUMENT_ROOT'].'/dbBackup/backupDBCODE/'.$dbname .'-'. date("Y-m-d-H-i-s") . '.sql.gz';    
        //echo "<br>&nbsp;".
        $command = "mysqldump –opt -h $dbhost -u $dbuser –password='$dbpass' $dbname | gzip > $backup_file";
        exec($command, $output);

  3. prafulkr says:

    All Database Backup in Mysql:

    $dbhost = 'localhost';
        $dbname = '–all-databases';
        $dbuser = 'pksqueak';
        $dbpass = 'pk@admin$9';
        $backup_file = $_SERVER['DOCUMENT_ROOT'].'/dbBackup/backupDBCODE/AllLocalDB'.'-'. date("Y-m-d-H-i-s") . '.sql.gz';    
        $command = "mysqldump –opt -h $dbhost -u $dbuser –password='$dbpass' $dbname | gzip > $backup_file";
        exec($command, $output);
        $changePermission = "chmod -Rf 777 $backup_file";

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>