Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am dropping Linode because I have unavailability of the Linux sysadmin skills necessary; before I accomplish the transition to a more noob-friendly service, I have to fetch and download content from MySQL database. Can it be done using the command line?

1 Answer

0 votes
by (11.7k points)

There are a couple of options available for MySQL dump.

It can be accomplished using the mysqldump command-line function.

For instance:

If it's an entire DB:

$ mysqldump -u [uname] -p db_name > db_backup.sql

In case of all DBs:

$ mysqldump -u [uname] -p --all-databases > all_db_backup.sql

In case there are specific tables within a DB:

$ mysqldump -u [uname] -p db_name table1 table2 > table_backup.sql

Or you can also use auto-compressing the output using gzip in the case of the very big database:

$ mysqldump -u [uname] -p db_name | gzip > db_backup.sql.gz

In case you want to do this remotely and you have the access to the server in question, then follow the steps( I am assuming the MySQL server is on port 3306):

$ mysqldump -P 3306 -h [ip_address] -u [uname] -p db_name >db_backup.sql

It will drop the .sql file in the folder you run the command-line from.

Related questions

0 votes
1 answer
asked Feb 28, 2021 in Linux by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
4 answers
asked Feb 28, 2021 in SQL by adhiraj (4k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...