From http://blog.csdn.net/bjtang/article/details/6571760
Export Database files from a database:
1. Export the database mydb to the E:/MySQL/mydb. SQL file:
Open start> RUN> Enter cmd to enter Command Line Mode
C:/> mysqldump-H localhost-u root-P mydb> E:/MySQL/mydb. SQL
Enter the password and wait for a moment until the export is successful. You can check whether the export is successful in the target file.
2. Export mytable in mydb to the E:/MySQL/mytable. SQL file:
C:/> mysqldump-H localhost-u root-P mydb mytable> E:/MySQL/mytable. SQL
3. Export the database mydb structure to the E:/MySQL/mydb_stru. SQL file:
C:/> mysqldump-H localhost-u root-P mydb -- add-drop-Table> E:/MySQL/mydb_stru. SQL
//-H localhost can be omitted, which is generally used on a VM.
4. import data from external files to the database:
Import the SQL statements in the file into the database from E:/MySQL/mydb2. SQL:
1. Enter MySQL from the command line, and then run the create database mydb2 command to create the database mydb2.
2. To exit MySQL, enter the command exit or quit;
3. Enter the following command in cmd:
C:/> mysql-H localhost-u root-P mydb2 <E:/MySQL/mydb2. SQL
Then enter the password, and then OK.
5. Next, let's talk about how to solve the import file size restriction problem:
By default, MySQL has a limit on the size of the imported file. The maximum size is 2 MB. Therefore, when the file is large, it cannot be imported directly. The following is a solution to this problem:
1. Modify related parameters in PHP. ini:
There are three parameters that affect the size of the MySQL import file:
Memory_limit = 128 M, upload_max_filesize = 2 m, post_max_size = 8 m
Modify upload_max_filesize = 200 M. Modify the size that meets your needs,
You can modify two other memory_limit = 250 m post_max_size = 200 m at the same time.
In this way, the. SQL file below MB can be imported.
In the above article, we put MySQL in the system path. In fact, we may as well. For example, my MySQL installation directory is D:/MySQL Server 5.0;
First open the DOS window with cmd, then enter D :( no '/') and press ENTER
At this time, the Mark D:/> should appear, and enter D:/MySQL Server 5.0/bin after it (the order is reversed)
D:/MySQL Server 5.0/bin> appears. Enter mysqldump-u username-P Database Name> database name. SQL (you can also enter the path). For more information, see the preceding section.
The file to be imported is also changed to '>' <. Or use source directly:
Common source commands
Go to the MySQL Database Console,
For example, MySQL-u root-P (unnecessary, omitted)
Mysql> Use Database
Then run the source command. The following parameter is the script file (for example,. SQL used here)
Mysql> source D: wcnc_db. SQL