By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
IT Infras HolicIT Infras HolicIT Infras Holic
  • News
  • Linux
    • Application
    • SELinux
    • Centos
    • Ubuntu
  • Docker
  • Web Server
    • Kong
    • Nginx
    • Openlitespeed
  • Database
  • Mikrotik
  • Windows
  • Mail
  • Tools
    • 2048
    • Fantasy Forest
    • Hextris
    • Crossword
Search
  • Privacy Policy
© 2024. All Rights Reserved.
Font ResizerAa
IT Infras HolicIT Infras Holic
Font ResizerAa
  • News
  • Linux
  • Docker
  • Web Server
  • Database
  • Mikrotik
  • Windows
  • Mail
  • Tools
Search
  • News
  • Linux
    • Application
    • SELinux
    • Centos
    • Ubuntu
  • Docker
  • Web Server
    • Kong
    • Nginx
    • Openlitespeed
  • Database
  • Mikrotik
  • Windows
  • Mail
  • Tools
    • 2048
    • Fantasy Forest
    • Hextris
    • Crossword
Follow US
© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.
IT Infras Holic > Blog > Database > Backup Restore MySQL Database
DatabaseLinux

Backup Restore MySQL Database

writer
Share
5 Min Read
SHARE

Backup Restore MySQL Database

It is very essential to make regular backups of all data to prevent data loss. Has your MySQL database has been lost, and you’re scrambling to restore a copy from your last backup? Read these step below carefully to Backup Restore MySQL Database using mysqldump & phpMyAdmin.

Contents
Backup Restore MySQL DatabaseBack Up MySQL Database Using mysqldumpExampleBackup of an entire Database Management System:Restore MySQL Using mysqldumpStep 1: Create New DatabaseStep 2: Restore MySQL DumpBackup Restore MySQL Database Using phpMyAdminStep 1: Create a MySQL Database BackupStep 2: Clear the Old Database InformationStep 3: Restore Your Backed up MySQL Database

Back Up MySQL Database Using mysqldump

The mysqldump client utility can dump a database including the SQL statements required to rebuild the database.

By default, the dump file includes the SQL commands to restore the tables and data.

Here is the syntax of mysqldump to backup MySQL Database

1
sudo mysqldump -u [user] -p [database_name] > [filename].sql

Note:

  • Replace [user] with your username and password (if needed).
  • The [database_name] is the path and filename of the database.
  • The > command specifies the output.
  • [filename] is the path and filename you want to save the dump file as.

Example

Backup of an entire Database Management System:

1
mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p

You include more than one database in the backup dump file:

1
sudo mysqldump -u [user] -p [database_1] [database_2] [database_etc] > [filename].sql

Restore MySQL Using mysqldump

Step 1: Create New Database

On the system that hosts the database, use MySQL to create a new database.

Make sure you’ve named it the same as the database you lost. This creates the foundation file that mysqldump will import the data into. Since the dump file has the commands to rebuild the database, you only need to create the empty database.

Step 2: Restore MySQL Dump

To restore a MySQL backup:

1
mysql -u [user] -p [database_name] < [filename].sql

Note: Backup Restore MySQL Database

Make sure to include [database_name] and [filename] in the path.

It’s likely that on the host machine, [database_name] can be in a root directory, so you may not need to add the path. Make sure that you specify the exact path for the dump file you’re restoring, including server name (if needed).

Backup Restore MySQL Database

Backup Restore MySQL Database Using phpMyAdmin

Read these steps carefully to Backup Restore MySQL Database

Step 1: Create a MySQL Database Backup

1. Open phpMyAdmin. On the directory tree on the left, click the database you want to back up.

This should open the directory structure in the right-hand window. You’ll also notice that, in the directory tree on the left, all the assets under the main database are highlighted.

2. Click Export on the menu across the top of the display.

You’ll see a section called “Export Method.” Use Quick to save a copy of the whole database. Choose Custom to select individual tables or other special options.

Leave the Format field set to SQL, unless you have a good reason to change it.

3. Click Go. If you select Quick, your web browser will download a copy of the database into your specified downloads folder. You can copy that to a safe location.

Step 2: Clear the Old Database Information

It’s important to clear out old data before restoring a backup. If there’s any old data, it isn’t overwritten when you restore. This can create duplicate tables, causing errors and conflicts.

1. Open phpMyAdmin, on the navigation pane on the left, choose the database you want to restore.

2. Click the check all box near the bottom. Then, use the drop-down menu labeled With selected to select Drop.

3. The tool should prompt you to confirm that you want to go forward. Click yes.

This will get rid of all the existing data, clearing the way for your restoration.

 

Step 3: Restore Your Backed up MySQL Database

In phpMyAdmin, the Import tool is used to restore a database.

1. On the menu across the top, click Import.

2. The first section is labeled File to import. A couple of lines down, there’s a line that starts with “Browse your computer,” with a button labeled Choose File. Click that button.

3. Use the dialog box to navigate to the location where you’ve saved the export file that you want to restore. Leave all the options set to default. (If you created your backup with different options, you can select those here.)

4. Click Go.

Easy?Isn't it? That's how to backup restore mysql database in simple steps.

You Might Also Like

Monitoring File & Directory Changes using Bash Script

Vulnerability Checker CVE-2024-3094

Unleashing the Potential of Knowledge Management with Wiki.js

How to Install Apache Guacamole with Docker Compose

Unlocking Seamless Remote Access: Exploring the Power of Apache Guacamole

TAGGED: backup mysql, mysql, mysqldump, phpMyAdmin, restore mysql
Share This Article
Facebook Twitter Whatsapp Whatsapp LinkedIn Telegram Copy Link
Previous Article add delete route in linux Add Delete Route in Linux CentOS 7
Next Article configure firewalld Configure FirewallD for Mail Server in Centos 7
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Latest News

bash
Monitoring File & Directory Changes using Bash Script
Linux Application
vulnerability
Vulnerability Checker CVE-2024-3094
Linux
wiki.js
Unleashing the Potential of Knowledge Management with Wiki.js
Application Linux
Install Apache Guacamole
How to Install Apache Guacamole with Docker Compose
Application Linux

You Might also Like

How to Install Cyberpanel on Ubuntu 22.04
OpenlitespeedUbuntuWeb Server

Install Cyberpanel on Ubuntu 22.04

8 Min Read
How to map SFTP as a drive on Windows 10
LinuxWindows

How to map SFTP as a drive on Windows 10

3 Min Read
Follow US
© 2024
activity notes activity notes
Welcome Back!

Sign in to your account

Lost your password?