How to import an Access database to Mysql _ PHP Tutorial

Source: Internet
Author: User
One of the methods for importing an Access database to Mysql. If you cannot import or export data between different databases, it is a terrible thing. Fortunately, different methods and methods can be used in various ways, if I cannot import or export data between different databases, it will be a terrible thing. Fortunately, different methods and methods can be used in a variety of ways, I provide one of them and provide my own solutions, which are 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 the file to 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 the import record
{
$ 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,

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.