Import an Access database to MySQL

Source: Internet
Author: User

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,

 
 
  1. $row = file("ipadress.txt");  

Read the content of a file to an array.

 
 
  1. $num=count($row); 

Total number of records in the statistical table

 
 
  1. MySQL_connect("localhost","root",""); 

Connect to database

 
 
  1. MySQL_select_db("cht");   
  2. for ($i=0;$i<$num;$i++) 

Start importing MySQL records

 
 
  1. {
  2. $ Fields = explode (",", $ row [$ I]);
  3. // Echo $ fields [0];
  4. // Echo $ fields [1];
  5. // Echo $ fields [2];
  6. MySQL_query ("insert into ipaddress (area_h, area_f, address) values ('$ fields [0]', '$ fields [1]', '$ fields [2]') ");
  7. }
  8. 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.

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.