MySQL –– Using phpMyAdmin to backup your database
written by: admin
Date Written: 3/18/10
Last Updated: 7/29/13
Note: This article assumes that you have access to your phpMyAdmin, but do not have full admin priviledges, which is often the case with shared servers. There are two ways to go about this. You can backup the database or backup the tables in the database.
Option 1: Backup the entire database
Log in to phpMyAdmin. Click
export link. Next use the default values then check
Save as file and
none.
NOTE: Make sure that you do not select the information_schema database, because you will not be able to upload it. It is not a big deal if you do. You will just get an error message saying that the database can't be imported, but your other database(s) will be uploaded.
To restore your database delete the database you are restoring and then select
import and upload your database.
The
export database page should look like this.
To delete your database you will need to create a php file to do so. It should look something like this:
<?php
include 'dbconnect.php';
mysqli_query($connect,'DROP DATABASE db_name');
?>
dbconnect.php is the name of a file that you have written that connects to the database.
Option 2: backup the tables
Click on the databse that you want to backup and click on export. Here different export options will be given. You will be asked to select the tables that you want to backup. Use the default options here and select
Save as file and
none. In addition to that check off
Add IF NOT EXISTS and
Add DROP TABLE / VIEW / PROCEDURE / FUNCTION and then go.
To upload click on Import and navigate to the sql file you want to upload and upload it.
The export tables page should look something like this:
Differences between the options:
- If a table is missing it will be added.
- If a table has a different structure or is missing or is missing data or has different data it does not matter because it will be replaced.
- If there is a table in your database that is not in your backup file the imported tables will leave the already existing tables intact.
TAGS: mysql