top of page
  • Writer's pictureRahul R

How to import and export a MySQL Database via Terminal

Importing and exporting MySQL databases via the terminal is a quick and efficient way to backup or transfer your data between different servers or hosting environments. In this blog post, we will discuss the steps for importing and exporting MySQL databases using the command line.


Exporting a MySQL Database via Terminal: To export a MySQL database, you will need to use the mysqldump command. The syntax for this command is as follows:


mysqldump -u [username] -p [database_name] > [backup_file.sql]


Replace [username] with your MySQL username, [database_name] with the name of the database you want to export, and [backup_file.sql] with the name you want to give to your backup file. The ‘>’ symbol is used to redirect the output to the backup file.


Example:


mysqldump -u root -p my_database > my_database_backup.sql


This command will create a backup file named my_database_backup.sql in the current directory.


Importing a MySQL Database via Terminal: To import a MySQL database, you will need to use the mysql command. The syntax for this command is as follows:


mysql -u [username] -p [database_name] < [backup_file.sql]


Replace [username] with your MySQL username, [database_name] with the name of the database you want to import the data into, and [backup_file.sql] with the name of the backup file that contains the data. The ‘<’ symbol is used to read the input from the backup file.


Example:


mysql -u root -p my_database < my_database_backup.sql


This command will import the data from my_database_backup.sql into the my_database database.

24 views0 comments

Recent Posts

See All

How to setup reverse proxy on apache2

To set up a reverse proxy to a local installation using Apache2, you need to configure the Apache Virtual Hosts to forward requests to your local server. Here's a step-by-step guide: Enable Proxy Modu

How to Set Up Odoo with Apache Reverse Proxy on Ubuntu

Welcome, adventurous souls, to the whimsical world of Odoo installation! In this zany tutorial, we'll embark on a wild journey to set up Odoo, the beloved open-source ERP software, with an Apache reve

How to Attach S3 to your Django Project

Install Required Packages: Install django-storages package, which provides support for various storage backends including Amazon S3. You can install it via pip: pip install django-storages Configure D

Comments


bottom of page