MySQL dump, a client utility program for the MySQL database engine, can be used to backup a MySQL database by exporting a ".sql" file type that contains SQL commands that can be used to reconstruct the original database.
You must have access to a server running a MySQL instance in order to use the mysqldump program. You'll also need user credentials for the database you want to export, as well as the necessary rights. The mysqldump utility may generate CSV, delimited text, and XML files in addition to.sql files.
How Do We Use mysqldump?
mysqldump -u USERNAME -p PASSWORD DBNAME > DBBACKUP.sql
mysqldump -u USERNAME -p PASSWORD --databases DB1 DB2 DB3.. >DBBACKUP.sql
mysqldump -u USERNAME -p PASSWORD --all-databases > ALLDBBACKUP.sql
Parameters | Signifies |
-u | It specifies your MySQL username. |
-p | It specifies your MySQL password. |
DBNAME | The name of the database that you want to backup. |
DBBACKUP.sql | The name of the backup file you want to generate. |
-h | It specifies the hostname of the MySQL database server. |
–databases | It is used to determine the database. |
-all-databases | It is used to backup all databases. |
–default-auth=plugin | It is used to specify the client-side authentication plugin to use. |
–compress | It is used to enable compression in server/client protocol. |
-P | It is used to specify the port number to use for MySQL connection |