Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access to MySQL Conversion help (Gigantic table)

So I have this gigantic table, containing approx 7 million records, in MS Access (*.mdb), I want to transfer it into a much more workable MySQL format, and store it on my webserver. The file itself weighs 2GB.

The problem is, since the table is so large, it won't let me export it normally (Access says the limit is 65,536 records.)

I've tried some 3rd party software but to no avail.

Can anyone recommend a clean way of doing so, without damaging the data inside?

Thanks in advance for any help.

like image 407
Madara's Ghost Avatar asked Aug 08 '11 17:08

Madara's Ghost


People also ask

Can you convert an Access database to MySQL?

Right click on the table you want to export, and in the menu that appears, choose Export , ODBC Database. The Export dialog box appears. Enter the desired name for the table after its import into the MySQL server, and click OK.

Can Microsoft Access handle big data?

General. 2 gigabytes, minus the space needed for system objects. Note: You can work around this size limitation by linking to tables in other Access databases. You can link to tables in multiple database files, each of which can be as large as 2GB.

How do I export more than 65000 rows in Access?

To export more than 65000 rows with formatting and layout then an option is to set up a query to export 65000 rows at a time into separate spreadsheets, then copy and paste together into one spreadsheet.

Can MS Access be used as a data conversion engine?

Answer: Yes. MS Access can be used as a data conversion engine. Data Conversion is the translation of computer data from one format to another. Microsoft Access is one of the most popular desktop database management system widely used in organizations that operate on Microsoft Windows.


2 Answers

Install an ODBC driver for MySQL, if you don't have one already. The latest version is available here: Download Connector/ODBC

Create a DSN (Data Source Name) for your MySQL server from the Windows ODBC Data Source Administrator.

Then from Access 2003, select your table in the Database Window, and choose File->Export from Access' main menu. In the "Export Table 'yourtablename' To ..." dialog, select "ODBC Databases()" from the "Save as type" drop-down list (at the bottom of the dialog). The next dialog allows you to specify the name MySQL will use for the exported table, and it defaults to the Access table name. After you click OK, you will get another dialog, "Select Data Source", where you can select your DSN for MySQL. After you click OK on that dialog, you will probably get one more asking you for user name and password. Supply them, and click OK.

Hopefully your table will then transfer without errors. However, I've never done that operation with MySQL. It has worked for me with ODBC transfers to SQL Server and PostGreSQL. So I don't see why it wouldn't work with MySQL, too.

Also I've never attempted to export 7 million records in one go. If it chokes, we'll have to figure out a work-around.

If you're using Access 2007 instead of 2003, look for a similar option starting with the Export section of the ribbon.

I suggested this approach because my impression is this export will be a one-time deal, so I think the Access UI export method would be easiest. However, you can do essentially the same operation with VBA code using the DoCmd.TransferDatabase Method with your ODBC DSN.

Yet another alternative would be to create a compatible table structure in MySQL, create a link in Access to the MySQL destination table (using your DSN again), then run an "append query" from Access:

INSERT INTO link_to_mysql_table (field1, field2, field3, etc)
SELECT field1, field2, field3, etc
FROM access_table;

The append query approach could be useful in case the export chokes on 7 million records. You could add a WHERE clause to limit the SELECT query's output record set to a manageable chunk size, and then repeat with a different WHERE to specify another chunk.

like image 85
HansUp Avatar answered Oct 12 '22 22:10

HansUp


Is that 7 million value after a compact + repair? I mean, if each record is about 120 chars in length, you can fit 32 million records in 2 gigs.

Also, I not aware of a limit of exporting 65,000 records, but only in regards to Excel.

So, you can/should be able to export the data to a csv, and then use a bulk text import in mySql to pull that data in. So, try exporting the table as csv. That should work.

I mean, you could link a table via odbc if you have a good local connection to the sql server, but if not, then I would export to csv (it is VERY fast). I would then zip the file (they zip fantastic). Upload file to server, and un-zip, and then use bulk text import. So, such a zipped file is VERY small and will save huge amounts of transfer time.

You can also consider using tab delimited as mySql also can import those, but a simple text file should work just fine.

like image 40
Albert D. Kallal Avatar answered Oct 12 '22 22:10

Albert D. Kallal