How to import and export a large amount of data by MySQL
This article introduces the knowledge of "how to import and export a large amount of data from MySQL". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
You must have used the database import and export function in phpmyadmin, which is very convenient. However, in practical application, I found the following problems:
1 database more than a certain size, such as 6m when the use of export is generally no problem, can be correctly saved to the local hard disk, but import is not! The reason is: in general, PHP.INI sets the size limit of temporary files / uploaded files to 2m, while phpmyadmin uses the method of uploading, resulting in failure.
When the .SQL file exported to the hard disk is imported back, it often fails due to some problems in single quotation marks, so it can only be imported by mysql and other application programs. My database has exceeded 10m, so this problem must be solved. My train of thought:
Export: save the database / table structure with phpmyadmin, read the database contents with scripts and save them to a file!
Import: restore the database / table structure with phpmyadmin, read the file with a script, and save it to the library!
The export program is as follows: the calling method is * .phptable=tablename
This simple program currently saves one table at a time! Data of one field per behavior! The following is the referenced content:
< if ($table== ") exit (); mysql_connect (" localhost "," name "," password "); mysql_select_db (" database "); $result=mysql_query (" select*from$table "); if (mysql_num_rows ($result)