How to import MySQL database 1. Overview
There are two ways to import a MySQL database:
1) export the Database SQL script first and then import it;
2) directly copy database directories and files.
In different operating systems or MySQL versions, the method of directly copying files may be incompatible.
Therefore, we recommend that you use SQL scripts to import data. The following describes two methods.
2. Method 1: SQL script
The procedure is as follows:
2. 1. export an SQL script
On the original database server, you can use the phpMyAdmin tool or the mysqldump command line to export the SQL script.
2.1.1 phpMyAdmin
Select "structure" and "data" to export. do not add the "DropDATABASE" option.
Select the "Save as file" option. if there is more data, select the "gzipped" option.
Save the exported SQL file.
2.1.2 use mysqldump command line
Command format
Mysqldump-u username-p database name> database name. SQL
Example:
Mysqldump-uroot-pabc> abc. SQL
(Export the database abc to the abc. SQL file)
Enter the password of the database user name when prompted.
2. create an empty database
Create a database on the master page/control panel. Assume that the database name is abc and the database full user is abc_f.
2. 3. import and execute SQL scripts
You can use either phpMyAdmin or mysql command line.
2.3.1 use phpMyAdmin
From the control panel, select the created empty database and click "Manage" to go to the management tools page.
In the "SQL" menu, browse and select the exported SQL file, and click "run" to load and execute the file.
Note: phpMyAdmin has a limit on the size of the uploaded file, and php itself has a limit on the size of the uploaded file. if the original SQL file
Relatively large, you can use gzip to compress it. for text files such as SQL files, you can obtain a compression rate of or higher.