The following article describes how to import an Access database to a MySQL database. We all know that importing and exporting data between different databases is terrible, however, it is fortunate that different methods and approaches are generally used.
There are many ways to achieve this. I provide one of them and one of my own solutions, which is intended to inspire others,
Step 1: first, the access database uses its own export function to customize a txt text document that is easy to operate on it, which is also the key to the next operation.
Step 2: first create a table with the same structure in MySQL. Of course, this step can be implemented using a program in step 3. I am sorry because of the rush of time)
Step 3: programming by yourself. You can use the program to read each record of the exported file and write it into the MySQL DATA table,
- $row = file("ipadress.txt");
Read the content of a file to an array.
- $num=count($row);
Total number of records in the statistical table
- MySQL_connect("localhost","root","");
Connect to database
- MySQL_select_db("cht");
- for ($i=0;$i<$num;$i++)
Start importing MySQL records
- {
- $ Fields = explode (",", $ row [$ I]);
- // Echo $ fields [0];
- // Echo $ fields [1];
- // Echo $ fields [2];
- MySQL_query ("insert into ipaddress (area_h, area_f, address) values ('$ fields [0]', '$ fields [1]', '$ fields [2]') ");
- }
- Echo "imported successfully! A total of $ num records are imported ,";
The above operations are performed on an IP address table on the Internet. If you are interested, try it. The above content is an introduction to the method for importing an Access database to MySQL, I hope you will have some gains.