This article describes how to import, export, and restore a MySQL database. For more information about MySQL database operations, see the following, it can be divided into two situations: virtual host and server.
Virtual host
1. through PHPMyAdmin's import and export function, this software generally only supports export of several megabytes of data, and too much data may time out.
2. you can use the database backup and restoration function provided by the program. some common PHP programs, such as the DZ Forum, have Database restoration and backup functions in the background, so that we can transfer space data.
3. if your database is purchased in the morning and evening data, our management panel supports one-click backup and restoration. After you click the backup button, you can download the data from the database space through FTP.
Server or VPS
First, we remotely connect to the server (either Windows or Linux) and prepare the root password or the user name and password of the specific database.
I. database import (restoration)
1. source Command
1) Choose start> Program> MySQL Command Line Client and enter the root password of MySQL.
2) then enterUse database name;
Enter the corresponding database, and then useThe specific path of the source backup file;
Command to import the backup file. Note that the command here must be followed by a semicolon, as shown below:
2. mysql commands
1) in Windows, enter the bin directory of mysql in command line mode, for example, D: \ Program \ mysql41 \ bin. For a Linux system, see the following steps.
2) execute the mysql command to import the database. the command format is:
Mysql-u username-p password database name <备份文件具体路径< p>
For example:Mysql-uroot-pabc123 mydb The user name and password can also be specific to the database, not necessarily root. As follows:
II. database export (backup)
Use the mysqldump command
1) in Windows, enter the bin directory of mysql in command line mode, for example, D: \ Program \ mysql41 \ bin. For a Linux system, see the following steps.
2) execute the mysqldump command to import the database. the command format is:
Mysqldump-u username-p password database name> Specific backup file path
For example:mysqldump -uroot -pabc123 mydb>file.sql
The user name and password can also be specific to the database, not necessarily root. If the when using lock tables error occurs, add -- skip-lock-tables to the database. As follows: