Downloading MySQL dump from command line

2020-01-24 09:57发布

I am moving away from Linode because I don't have the Linux sysadmin skills necessary; before I complete the transition to a more noob-friendly service, I need to download the contents of a MySQL database. Is there a way I can do this from the command line?

10条回答
做个烂人
2楼-- · 2020-01-24 10:34

Go to MySQL installation directory and open cmd from there. Then execute the below command to get a backup of your database.

mysqldump -u root -p --add-drop-database --databases db> C:\db-dontdelete\db.sql
查看更多
孤傲高冷的网名
3楼-- · 2020-01-24 10:35

For Windows users you can go to your mysql folder to run the command

e.g.

cd c:\wamp64\bin\mysql\mysql5.7.26\bin
mysqldump -u root -p databasename > dbname_dump.sql
查看更多
我命由我不由天
4楼-- · 2020-01-24 10:38

Open Command prompt, and directly type this command. Don't go inside mysql and then type this command.

mysqldump -u [uname] -p[pass] db_name > db_backup.sql
查看更多
我命由我不由天
5楼-- · 2020-01-24 10:39

If downloading from remote server, here is a simple example:

mysqldump -h my.address.amazonaws.com -u my_username -p db_name > /home/username/db_backup_name.sql

The -p indicates you will enter a password, it does not relate to the db_name. After entering the command you will be prompted for the password. Type it in and press enter.

查看更多
▲ chillily
6楼-- · 2020-01-24 10:39

If you are running the MySQL other than default port:

mysqldump.exe -u username -p -P PORT_NO database > backup.sql
查看更多
Animai°情兽
7楼-- · 2020-01-24 10:40

Use this If you have the database with the name archiedb, use this mysql -p --databases archiedb > /home/database_backup.sql

Assuming this is linux, choose where the backup file will be saved.

查看更多
登录 后发表回答