如何将 MDB (Access) 文件转换为 MySQL(或普通 SQL 文件)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5722544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I convert an MDB (Access) file to MySQL (or plain SQL file)?
提问by Bryan Field
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.
是否可以从 Microsoft Access 数据库创建 SQL 命令转储?我希望将此 MDB 文件转换为 MySQL 数据库以进行导入,这样我就不必经过 CSV 步骤。
I would expect even an MSSQL dump file to still contain workable SQL commands, but I know nothing of MSSQL, please let me know.
我希望即使是 MSSQL 转储文件仍包含可用的 SQL 命令,但我对 MSSQL 一无所知,请告诉我。
回答by Teson
You want to convert mdb to mysql (direct transfer to mysql or mysql dump)?
你想把mdb转mysql(直接转mysql或者mysql dump)?
Try a software called Access to MySQL.
尝试使用名为Access to MySQL的软件。
Access to MySQLis 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.
Access to MySQL是一个将 Microsoft Access 数据库转换为 MySQL的小程序。
- 向导界面。
- 将数据直接从一台服务器传输到另一台服务器。
- 创建转储文件。
- 选择要传输的表。
- 选择要传输的字段。
- 传输受密码保护的数据库。
- 支持共享安全和用户级安全。
- 可选的索引传输。
- 可选的记录传输。
- 字段定义中默认值的可选传输。
- 识别和传输自动编号字段类型。
- 命令行界面。
- 易于安装、卸载和升级。
See the aforementioned link for a step-by-step tutorial with screenshots.
有关带屏幕截图的分步教程,请参阅上述链接。
回答by Nicolay77
If you have access to a linux box with mdbtools installed, you can use this Bash shell script (save as mdbconvert.sh):
如果您可以访问安装了 mdbtools 的 linux 机器,您可以使用这个 Bash shell 脚本(另存为 mdbconvert.sh):
#!/bin/bash
TABLES=$(mdb-tables -1 )
MUSER="root"
MPASS="yourpassword"
MDB=""
MYSQL=$(which mysql)
for t in $TABLES
do
$MYSQL -u $MUSER -p$MPASS $MDB -e "DROP TABLE IF EXISTS $t"
done
mdb-schema mysql | $MYSQL -u $MUSER -p$MPASS $MDB
for t in $TABLES
do
mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $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.
它将导入所有表和所有数据。
回答by mikkom
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.
我修改了 Nicolay77 的脚本以将数据库输出到标准输出(unix 脚本的常用方式),以便我可以将数据输出到文本文件或通过管道将其传输到我想要的任何程序。生成的脚本更简单一些并且运行良好。
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)
这是修改后的脚本(保存到 mdb_to_mysql.sh)
#!/bin/bash
TABLES=$(mdb-tables -1 )
for t in $TABLES
do
echo "DROP TABLE IF EXISTS $t;"
done
mdb-schema mysql
for t in $TABLES
do
mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $t
done
回答by Ivan Cachicatari
Free database tools don't export table RELATIONSHIPS, but you can use this: converting MS Access to MySQL with relationships
免费数据库工具不导出表 RELATIONSHIPS, 但您可以使用它:将 MS Access 转换为 MySQL 与关系
Works fine and export all relationships to MySQL.
工作正常并将所有关系导出到 MySQL。
回答by Egor Guriyanov
OSX users can follow by Nicolay77or mikkomthat uses the mdbtoolsutility. You can install it via Homebrew. Just have your homebrew installed and then go
OSX用户可以通过遵循Nicolay77或mikkom使用该mdbtools效用。您可以通过Homebrew安装它。只需安装你的自制软件然后去
$ 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.
然后创建这些家伙描述的脚本之一并使用它。我使用了 mikkom 的一个,将我所有的 mdb 文件转换为 sql。
$ ./to_mysql.sh myfile.mdb > myfile.sql
(which btw contains more than 1 table)
(顺便说一下,其中包含 1 个以上的表)
回答by Michael Pryor
We've used ESF Database Convertmany times for this exact purpose. DTS was usually too flakey. And the recommendations on the MySQL page were woefully out of date.
为此,我们多次使用ESF Database Convert。DTS 通常太古怪了。MySQL页面上的建议已经过时了。
回答by Tihonov Eugene
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 stringsto build connection string to your MS Access file.
试试MySQL的数据向导。它是一种将结构和数据从任何 ADO 兼容源(例如 MS Access)转换为 MySQL 数据库的工具。请参阅连接字符串的简要指南以构建到 MS Access 文件的连接字符串。
回答by Tihonov Eugene
Try the Data Transformation Servicesof microsoft
试试微软的数据转换服务
回答by Harsha
I've used SQLYog Ultimate to import data from mdb file, it was very easy process.
我已经使用 SQLYog Ultimate 从 mdb 文件导入数据,这是一个非常简单的过程。
you may need to install these support tool.
您可能需要安装这些支持工具。
and download SQLYog Ultimate below
并在下面下载 SQLYog Ultimate
回答by petednz - fuzion
This mac tool MDB / ACCDB Viewerworked 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.
这个 mac 工具MDB / ACCDB 查看器非常适合我的需求。免费试用让我证明一切都符合要求,并导出了所有行的一半。需要完整版才能导出整个数据库/表。