Last active
September 29, 2018 05:18
-
-
Save iforwms/f1c55257fc5203e47d70a2b22b4e92c9 to your computer and use it in GitHub Desktop.
mysqldump commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/13484667/downloading-mysql-dump-from-command-line | |
If it's an entire DB, then: | |
$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql | |
If it's all DBs, then: | |
$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql | |
If it's specific tables within a DB, then: | |
$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql | |
You can even go as far as auto-compressing the output using gzip (if your DB is very big): | |
$ mysqldump -u [uname] -p[pass] db_name | gzip > db_backup.sql.gz | |
If you want to do this remotely and you have the access to the server in question, then the following would work (presuming the MySQL server is on port 3306): | |
$ mysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name > db_backup.sql | |
============================ | |
Import: | |
mysql > use DB_NAME | |
mysql > source PATH_TO_SQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment