7/24/2019 Backup and Restore MySQL
1/16
SONY S. WIJAYA
Backup using phpMyAdmin
1.
Open phpMyAdmin
2. Select a database or table
3.
Click on the Exporttab
7/24/2019 Backup and Restore MySQL
2/16
SONY S. WIJAYA
4.
Click Kirim (Go), then the database will be downloaded.
7/24/2019 Backup and Restore MySQL
3/16
SONY S. WIJAYA
Restore using phpMyAdmin
1.
To restore (import) a database via phpMyAdmin, choose the database that will be where
the data imported to.
2.
Then, click on the Importtab
3. Choose the file from local computer
7/24/2019 Backup and Restore MySQL
4/16
SONY S. WIJAYA
4.
Then click Kirim (Go) to upload and import the database
7/24/2019 Backup and Restore MySQL
5/16
SONY S. WIJAYA
5.
The database imported/restored successfully
7/24/2019 Backup and Restore MySQL
6/16
SONY S. WIJAYA
Backup using MySQL Administrator
1.
Open MySQL Administrator and fill in the form based on MySQL service server and user
credentials
2.
If the log in successful, the serves status will appear
7/24/2019 Backup and Restore MySQL
7/16
SONY S. WIJAYA
3. To backup a database, click on Backup button from the left menu. After
that, click New Projectto create a backup project. Give a name for the project, then click
Save Project
7/24/2019 Backup and Restore MySQL
8/16
SONY S. WIJAYA
4.
Select which databases that will be backed up. After that, click on the right-pointing
arrow to mark the database for backup. Finally, click on the Execute Backup Nowto
start the database backup.
5.
Then, choose the location for the backup file. After that, click save. The database
successfully backed up.
7/24/2019 Backup and Restore MySQL
9/16
SONY S. WIJAYA
Restore using MySQL Administrator
1. Click on the Restore Button from the left menu. Next, click the Open Backup
Filebutton.
2.
Choose the database that will be restored. Then, click Open.
7/24/2019 Backup and Restore MySQL
10/16
SONY S. WIJAYA
3.
After file loaded, choose the target schema. If the database will be backed up in new
schema, choose New Schema and give it a name. If the database will be backed up in
original schema, choose Original Schema. Finally, click Start Restore.
4. If the restore process success, the new schema from backed up database will appear.
7/24/2019 Backup and Restore MySQL
11/16
SONY S. WIJAYA
Backup using MySQLDump
1.
First of all, open Command Prompt and change directory into bin folder of MySQL
2.
Backup a single database
a.
Type mysqldump -u rootp [name of database]> [directory destination and file
name]
b. After that, enter the password
c. If the backup successfully works, the new file of database will appear
3.
Backup all databases
a. My databases
b.
Type mysqldump-u rootp--all-databases> [directory destination and file name]
c.
After that, enter the password
d.
If the backup successfully works, the new file of database will appear
e. Verify the all_databases.sql dumpfile contains all of the databases backup.
f. Type findstri Current database:[file name and location]
7/24/2019 Backup and Restore MySQL
12/16
SONY S. WIJAYA
4.
Backup a specific table
a.
Choose a database and the table that will be backed up.
b. In CMD, type
mysqldump -u rootp[database name] [table name]>[directory destination and
file name]
c. After that, enter the password
d.
If the backup successfully works, the new file of database will appear
7/24/2019 Backup and Restore MySQL
13/16
SONY S. WIJAYA
Restore using MySQLDump
1.
First of all, create new database
2.
Then, open Command Prompt and change directory into bin folder of MySQL
3.
Type mysql -u root -p [database destination name] < [backup file name and location]
4.
After that, enter the password
5. Check the new restored database. The database successfully restored.
7/24/2019 Backup and Restore MySQL
14/16
SONY S. WIJAYA
Backup using MySQL
1.
Open the MySQL Client
2.
Before performing backup, the tables should be locked and flushed.
3.
First, use the database
4.
To lock the table, write mysql query:LOCK TABLES [table name]WRITE;
5.
To flush the tables, write mysql query:
FLUSH TABLES;
6.
Backup the result of SQL
a. Write mysql query:
SELECT * FROM [table name]INTO OUTFILE '[filename.txt]';
b. The result will be appearing as a txt file in the database folder. If the .txt file opened,
the records will appear in one line.
7/24/2019 Backup and Restore MySQL
15/16
SONY S. WIJAYA
c.
To export the students table in CSV format with CRLF-terminated lines, write mysql
query:
SELECT * FROM [table name]INTO OUTFILE '[filename.txt]'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';
d. CSV format gives better appearance
7. Backup database table
a. Write mysql query:
BACKUP TABLE [table name]TO [folder location];
NOTE
This statement is deprecated and is removed in MySQL 5.5.
As an alternative, mysqldumpor mysqlhotcopycan be used instead.
(https://dev.mysql.com/doc/refman/5.0/en/backup-table.html)
7/24/2019 Backup and Restore MySQL
16/16
SONY S. WIJAYA
Restore using MySQL
1.
Open the MySQL Client
2.
First, use the database
3.
Write mysql query:
LOAD DATA INFILE[file name]INTO TABLE[table name destination];
4.
The records will be added into students table
Top Related