How to restore a MySQL backup

Published on October 20th, 2020

SimpleBackups founder

Islam Essam

Co-founder, SimpleBackups

You already have your backup and decided to restore this on your MySQL database? In this article, we will tackle how to restore a MySQL backup using a simple command.

Table of Contents


  • MySQL installed
  • MySQL user credentials
  • A MySQL backup file; if you don't already have one, SimpleBackups provides an automated MySQL backup
  • An existing database

How to restore a MySQL backup

The following steps assume you already have a MySQL backup:

  1. Create a new MySQL database where you will restore your backup, or use an existing database.

  2. To restore the backup, use the command:

    mysql -u [user] -p [database_name] < [filename].sql
    • mysql - this is our main mysql program
    • -u [user] - this flag is used to specify which user we will use to access the database
    • -p - this flag signals that our user uses a password
    • [database_name] - this will be our database's name where we will restore our backup
    • < [filename].sql - this means that we will input(import) the contents of [filename].sql file into our [database_name] database


  • After entering this command, you may be asked to enter the password for the MySQL user that you used.
  • Please be careful when using an existing database that has records as this command will overwrite your existing database and end up losing your records.

Back to blog

Don't want to maintain backup scripts?

Unlock no-code & optimized backup, for all your projects.

Try SimpleBackups

No credit card required. Free 7-day trial.