Posted By

sergeygerasimov on 12/15/10


Tagged

mysql backup


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

qubestream
kendsnyder
MicronXD
tzvio


How to Back Up and Restore a MySQL Database


 / Published in: MySQL
 

URL: http://www.webcheatsheet.com/SQL/mysql_backup_restore.php#restore

  1. /* Back up From the Command Line (using mysqldump) */
  2. mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
  3.  
  4. /* Back up your MySQL Database with Compress */
  5. mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
  6.  
  7. /* Restoring your MySQL Database */
  8. mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Affix on December 19, 2010

Using -p[pass] is a pretty bad idea. This will log the password to .bash_history

instead just use the -p switch and mySQL will prompt you for the password of the user. That way it won't be logged to the bash_history file

You need to login to post a comment.