How can I convert an MDB (Access) file to MySQL (or plain SQL file)?

ε祈祈猫儿з 提交于 2019-12-29 02:18:13

问题


Is it possible to create a Dump of SQL commands from a Microsoft Access database? I hope to convert this MDB file into a MySQL database for importing so I don't have to go through the CSV step.

I would expect even an MSSQL dump file to still contain workable SQL commands, but I know nothing of MSSQL, please let me know.


回答1:


You want to convert mdb to mysql (direct transfer to mysql or mysql dump)?

Try a software called Access to MySQL.

Access to MySQL is a small program that will convert Microsoft Access Databases to MySQL.

  • Wizard interface.
  • Transfer data directly from one server to another.
  • Create a dump file.
  • Select tables to transfer.
  • Select fields to transfer.
  • Transfer password protected databases.
  • Supports both shared security and user-level security.
  • Optional transfer of indexes.
  • Optional transfer of records.
  • Optional transfer of default values in field definitions.
  • Identifies and transfers auto number field types.
  • Command line interface.
  • Easy install, uninstall and upgrade.

See the aforementioned link for a step-by-step tutorial with screenshots.




回答2:


If you have access to a linux box with mdbtools installed, you can use this Bash shell script (save as mdbconvert.sh):

#!/bin/bash

TABLES=$(mdb-tables -1 $1)

MUSER="root"
MPASS="yourpassword"
MDB="$2"

MYSQL=$(which mysql)

for t in $TABLES
do
    $MYSQL -u $MUSER -p$MPASS $MDB -e "DROP TABLE IF EXISTS $t"
done

mdb-schema $1 mysql | $MYSQL -u $MUSER -p$MPASS $MDB

for t in $TABLES
do
    mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $1 $t | $MYSQL -u $MUSER -p$MPASS $MDB
done

To invoke it simply call it like this:

./mdbconvert.sh accessfile.mdb mysqldatabasename

It will import all tables and all data.




回答3:


I modified the script by Nicolay77 to output the database to stdout (the usual way of unix scripts) so that I could output the data to text file or pipe it to any program I want. The resulting script is a bit simpler and works well.

Some examples:

./mdb_to_mysql.sh database.mdb > data.sql

./mdb_to_mysql.sh database.mdb | mysql destination-db -u user -p

Here is the modified script (save to mdb_to_mysql.sh)

#!/bin/bash
TABLES=$(mdb-tables -1 $1)

for t in $TABLES
do
    echo "DROP TABLE IF EXISTS $t;"
done

mdb-schema $1 mysql

for t in $TABLES
do
    mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $1 $t
done



回答4:


Free database tools don't export table RELATIONSHIPS, but you can use this: converting MS Access to MySQL with relationships

Works fine and export all relationships to MySQL.




回答5:


OSX users can follow by Nicolay77 or mikkom that uses the mdbtools utility. You can install it via Homebrew. Just have your homebrew installed and then go

$ homebrew install mdbtools

Then create one of the scripts described by the guys and use it. I've used mikkom's one, converted all my mdb files into sql.

$ ./to_mysql.sh myfile.mdb > myfile.sql

(which btw contains more than 1 table)




回答6:


Try the Data Wizard for MySQL. It is a tool for converting structure and data from any ADO-compatible source (e.g. MS Access) to MySQL databases. See a brief guide to connection strings to build connection string to your MS Access file.




回答7:


Try the Data Transformation Services of microsoft




回答8:


We've used ESF Database Convert many times for this exact purpose. DTS was usually too flakey. And the recommendations on the MySQL page were woefully out of date.




回答9:


I've used SQLYog Ultimate to import data from mdb file, it was very easy process.

you may need to install these support tool.

MS Access Database engine

and download SQLYog Ultimate below

Pick SQLYog, you can use trial version for this




回答10:


I use a Mac I do this to convert;

  1. Download ACCDB MDB Explorer http://accdb-mdb-explorer.en.softonic.com/mac
  2. Open the MDB file
  3. Export as SQL
  4. Import in MySQL using MySQL Workbench.



回答11:


This mac tool MDB / ACCDB Viewer worked well for my needs. Free trial let me prove everything did the required, and exported half of all rows. Full version was required to get the whole db/tables exported.




回答12:


I tried https://www.rebasedata.com/convert-mdb-to-mysql-online and it works pretty well.

Online solution without the need for registration.




回答13:


If you are not too concerned with the privacy of the .mdb files you want to convert, please know that this site allowed me to recover two 15-years-old .mdb Access databases (remember the old times when ASP ruled the web?) in just two minutes : http://www.mdbopener.com/

The databases were converted in Excel files, with one sheet for each table. Just what I needed. Couldn't have been any faster to recover my (very) old data...

The IDs being kept in each table, it was as easy as anything to convert this again to mysql (after saving it to CSV format) - again, in just a few minutes.



来源:https://stackoverflow.com/questions/5722544/how-can-i-convert-an-mdb-access-file-to-mysql-or-plain-sql-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!