The following article describes how to import Access data into the MySQL database. All of us go directly to the actual website construction process, we often process the import and export of some data. In MySQL databases, there are generally two ways to process data export:
1. Use select * from table_name into outfile "file_name ";
2. Use the MySQLdump Utility
The following is an example:
Assume that one database in our database is samp_db, and one table is samp_table. Now we need to export the data of samp_table. We can use the following methods to achieve this:
Enter
- select * from samp_table into outfile “file_name”;
Enter
- MySQLdump –u root samp_db samp_table >samp.sql
(Of course, MySQLdump has many options. For example,-d indicates that only the table structure is exported;-t indicates that only the table data is imported)
How to import data: Generally, we enter MySQLimport-u root samp_db samp_table.txt at the system command prompt. Note: The TXT file name must be named after the table name ). We can also use MySQL-u root samp_db <file_name to import data exported by MySQLdump to MySQL. At the MySQL prompt, we use Load data infile "file_name" into table samp_table.
In addition to the above methods, we can import and export data by copying files on the premise that the mobile database system is consistent with the original system. first, use MySQLadmin-u root variables at the system command prompt) or use show variables; At the MySQL prompt) to find datadir. For example, in my environment, the directory is c: \ MySQL \ data. Then copy some of the files. Everything is OK!
With the above knowledge, let's get started with the question: how to import ACCESS data into MySQL.
First, we export data from ACCESS as a text file. During the export process, select the field separator and text identifier, check the text file, and check whether a record is on the same line. If not, manually remove the Enter key. Assume that the exported text file is c: \ samp_table.txt. The content is as follows:
1. Zhang Xinhua, male
2. Jiang advanced, female
Next we use MySQLimport-u root-fields-terminated-by = "\," samp_db samp_table.txt, or load data infile "c: \ samp_table.txt "into table samp_table fields terminated by" \, "; Give It A Try (note the escape characters). Is everything OK! If not, take a closer look at the help of specific commands. Some options are listed below:
-- Fields-enclosed-by = char indicates that the column value should be included in the specified character. Quotation marks are usually used. The column value is not included in any character.
-- Fields-escaped-by = char indicates the escape character used to escape special characters. Lack of time-saving means no escape characters.
-- Fields-terminated-by = char specifies the characters of the columns to be separated. The missing time is assumed that the column values are separated by tabs.
The above content is an introduction to how to import Access data into MySQL.