Ask a question: how to import the txt file to the database? assume that [I] has a txt file containing 30 million data records for all users and passwords in CSDN. The first column is the user name, the second column is the password, and the third column is the mailbox.
Then we can get a txt file, but the first column is the mailbox, the second column is the user name, and the third column is the password.
There are more txt files with different sorting types.
I want to create a general import program. how can I store different txt files to the corresponding fields of the database in the form of "user name-password-mailbox, in this way, you can easily query the database. thank you!
Reply to discussion (solution)
We recommend that you use a mysql temporary table for the large data volume.
You can use the load data infile command to import DATA at high speed.
However, if the data file encoding is different from character_set_database, the data file will only be imported row by row.
Before import, you must have a user interaction page to manually confirm the import order.
You can use the load data infile command to import DATA at high speed.
However, if the data file encoding is different from character_set_database, the data file will only be imported row by row.
Before import, you must have a user interaction page to manually confirm the import order.
Before import, you must have a user interaction page to manually confirm the import order.
According to your meaning, does it mean that when I select to upload a file, let php read the first line of the file (usually the first line is in the same format as the following, only the length is different). after selection, let php automatically read and match?
Yes, which field of the table corresponds to which column of data must be checked clearly.
Yes, which field of the table corresponds to which column of data must be checked clearly.
Thank you for your reply.
Php loop should be okay, but I don't know how efficient it is.
This is very simple. it is the process of getting data and storing data. when getting the data, you can determine whether the first column is a mailbox. if it is a mailbox, the second column is a username and the third column is a password. If not, the first column is the user name, the second column is the password, and the third column is the mailbox. Then you can splice the string you want and store it in the database.