DEV Community

Cover image for How to Backup MySQL Database using mysqldump
Ayekple Clemence
Ayekple Clemence

Posted on • Originally published at anansewaa.com

3 1

How to Backup MySQL Database using mysqldump

Backup MySQL Database using mysqldump

One of the most common ways to backup MySQL database is to use a command called “mysqldump“.

Backing Up

The basic syntax of the command to backup mysql with mysqldump is:

mysqldump -u your_username -p database_to_backup > backup_file_name.sql 

Restoring Dumped Data

To restore a database backup we created with mysqldump, we have to point the file into MySQL again.
First, log into MySQL by typing:

mysql -u your_username -p

Second, we need to create a blank database to restore the data into. The command below create a new database which will hold all of the data that will dumped and then exit out of the MySQL prompt:

CREATE DATABASE new_database_name;
exit

Next, we can restore the dump database file into the newly created database by using the command below:

mysql -u username -p database_name < backup_file_name.sql

You should have all your information restored to the database you’ve created.
How to Reset MySql Root password on MacOS 10.13

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay