How to Export and Import a MySQL Database Using Command Line

How to Export and Import a MySQL Database Using Command Line

Having an up-to-date backup of your database is essential to protect your critical information and ensure business continuity. In this tutorial, we will show you how to export a database using the command line.
Info
It is important to perform a complete backup of the database before any procedure

Exporting the MySQL database

Open a terminal or command line on your operating system and run the following command to export the database:
  1. mysqldump -u [usuario] -p [base_de_datos] > [ruta_del_archivo.sql]
The command will run and export the database in SQL format to the specified file.

Importing the MySQL database 

Run the following command to import the database:
  1. mysql -u [usuario] -p [base_de_datos] < [ruta_del_archivo.sql]
 
Remember that this tutorial is a general example and the commands may vary depending on the database management system you are using. Make sure to adjust the commands and parameters according to your specific needs and configuration.