Home  >  Article  >  Backend Development  >  access database instance One of the methods of importing Mysql from Access database

access database instance One of the methods of importing Mysql from Access database

WBOY
WBOYOriginal
2016-07-29 08:33:301259browse

If you cannot import and export between different databases, it will be a terrible thing. Fortunately, in general, it can be achieved through different methods and approaches. There are many methods. I will provide one of them and provide one of my own. The processing idea is intended to inspire others.
The first step: first use the access database's own export function to customize a txt text document in a format that is easy to operate. This is also the key to the next step.
Step 2: First create a table with the same structure in mysql (of course, this step can be implemented with a program in step 3. Due to the rush of time, I couldn’t complete it, sorry)
Step 3: Program it yourself Now, find a way to use a program to read each record of the exported file and write it into the Mysql data table,
$row = file("ipadress.txt"); //Read the contents of the file into an array
$num=count($row);//The total number of records in the statistical table
mysql_connect("localhost", "root",""); //Connect to the database
mysql_select_db("cht");
for ($i= 0;$i<$num;$i++)//Start importing 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 "Import successful! A total of $num records were imported,";
The above operations are based on an IP address comparison table downloaded from the Internet. If you are interested, you can try it. Give it a try,

The above introduces one of the methods of access database instance and Access database importing Mysql, including the content of access database instance. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn