How to export SQL dump file of database via SSH

Post Reply
User avatar
isscbta
Team Member
Posts: 129
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 14 times
Been thanked: 3 times

If you are logged in as 'root' in SSH, then run:

Code: Select all

mysqldump database_name > data_dump.sql
If you are not logged in as 'root' in SSH, then you need login credentials for database:

Code: Select all

mysqldump -h localhost -u mysqlUsername --password='somepass' database_name > data_dump.sql
In order to run the said command, you will need to supply the following parameters:
  • hostname - it's localhost if you are dumping database from the same server
  • mysqlUsername - The username for MySQL.
  • password - The password of MySQL user.
  • database_name - The name of the database you want to backup.
  • data_dump.sql - The file name for your backup dump.
---

To export only specific tables:

Code: Select all

mysqldump database_name --tables table1 table2 table3 > data_dump.sql
---

Here you can find how to IMPORT sql dump file to the database: viewtopic.php?t=612

Tags:
Post Reply