mysqldump -h localhost -u username -p database_name > backup_db.sql
take a backup in compress mode:
mysqldump -u username -h localhost -p database_name | gzip -9 > backup_db.sql.gz
(OR)
mysqldump -u username -p database_name | gzip -c backup.sql.gz
Now, to explain what’s going on here! The “mysqldump” program is a tool for creating database backups. The parameters being used are:
- “-u” switch means you’re going to specify a username to connect with, which must follow, like “-u mysqluser” above
- “-p” switch means you’re either going to immediately specify the password to use (with no space), or it’ll prompt you for one
- The final parameter used in the example above is the name of the database to backup (of course!)
To place the contents of the output into a file, for back-up purposes, we need to use what’s called a redirection.
No comments:
Post a Comment