It is important for MYSQL database users to back up and restore MySQL. This article describes how to use the mysqldump and source commands to back up and restore MYSQL in Windows and Linux.
I. Restoration of MySQL backup in Win32 System
Backup: In "run", enter "cmd" and use "cd/Program Files/MySQL Server 5.0/bin" to enter the bin folder, enter "mysqldump-u username-p databasename> exportfilename" to export the database to a file, such as mysqldump-u root-p voice> voice. SQL, and then enter the password to start exporting MYSQL Data for backup.
Restore: Enter the MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", Press enter to see what database is there, and create the database you want to restore, enter "create database voice;", Press ENTER; switch to the database you just created, enter "use voice;", Press ENTER; import data, and enter "source voice. SQL; ", Press enter to start importing, and" mysql> "is displayed again. If no error is returned, the restoration is successful.
Ii. How to back up and restore MySQL in Linux:
Backup: [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation)
[Root @ localhost mysql] # mysqldump-u root-p voice> voice. SQL. Enter the password.
Restoration: two methods are available:
Method 1: [root @ localhost ~] # Mysql-u root-p press enter and enter the password to go To the MySQL console "mysql>", which is restored in the same way as 1.2.
Method 2:
[Root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation)
[Root @ localhost mysql] # mysql-u root-p voice