php 将 MS ACCESS DB 导入 mySql?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1453180/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:39:02  来源:igfitidea点击:

Importing MS ACCESS DB to mySql?

phpmysqlms-access

提问by Elitmiar

I'm working on a project atm, and I need to import data that is stored in a MS ACCESS database to mySql. For mySql I'm using phpMyAdmin on a Ubuntu machine, I have another Windows Machine where I can access the Access DB from, In MS Access 2003 I can't find an option to convert the data to mySql? Can this be done?

我正在处理一个项目 atm,我需要将存储在 MS ACCESS 数据库中的数据导入到 mySql。对于 mySql,我在 Ubuntu 机器上使用 phpMyAdmin,我有另一台 Windows 机器,我可以从中访问 Access DB,在 MS Access 2003 中,我找不到将数据转换为 mySql 的选项?这能做到吗?

回答by Druid

Take a look at Access to MySQL. Makes it easy to convert an Access database to MySQL.

看看访问 MySQL。使将 Access 数据库转换为 MySQL 变得容易。

回答by David-W-Fenton

It's always possible to do a quick and dirty export from Access to any ODBC database by selecting a table in Access and simply choosing EXPORT from the File menu. One of the export options (in the dropdown at the bottom) is ODBC, and if you have a DSN set up for your other database, you can export directly. Obviously, the data types won't necessarily be perfect for the target database, but it won't misconvert any data -- you just may need to tighten up the data types after the export.

通过在 Access 中选择一个表并简单地从“文件”菜单中选择“导出”,始终可以从 Access 快速且脏地导出到任何 ODBC 数据库。导出选项之一(在底部的下拉列表中)是 ODBC,如果您为其他数据库设置了 DSN,则可以直接导出。显然,数据类型不一定适合目标数据库,但它不会错误转换任何数据——您可能只需要在导出后收紧数据类型。

I think it's astonishing that Access can do this, to be honest, but it works.

老实说,我认为 Access 可以做到这一点令人惊讶,但它确实有效。

回答by tony gil

step by step guide to running Access frontend application with MySQL database on webserver (you dont need to IMPORT the tables, you can use your msaccess application WITH them on the webserver) and EXPORTING MsAccess tables to MySQL (once you start down that path, you want it to be a two-way road, believe me):

在网络服务器上运行带有 MySQL 数据库的 Access 前端应用程序的分步指南(您不需要导入表,您可以在网络服务器上使用带有它们的 msaccess 应用程序)和将 MsAccess 表导出到 MySQL(一旦你开始这条路,你希望它是一条双向的道路,相信我):

If you are running MsAccess, i suppose that you are using windows

如果您正在运行 MsAccess,我想您正在使用 Windows

  1. Install MySQL ODBC 5.1 Driver (connector) http://dev.mysql.com/downloads/connector/odbc/
  2. Open CONTROL PANEL on win machine
  3. ADMINISTRATIVE TOOLS (if Vista or Seven, search ODBC)
  4. SET UP DATA SOURCES ODBC
  5. SYSTEM DSN
  6. ADD
  1. 安装 MySQL ODBC 5.1 驱动程序(连接器)http://dev.mysql.com/downloads/connector/odbc/
  2. 在win机器上打开控制面板
  3. 管理工具(如果是 Vista 或 7,请搜索 ODBC)
  4. 设置数据源 ODBC
  5. 系统DSN
  6. 添加

depending on your server, you might have some difficulty finding the server name or IP, look for SSH Database connection (or something like that). as an example, read NetSol's FAQ: http://www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/

根据您的服务器,您可能很难找到服务器名称或 IP,查找 SSH 数据库连接(或类似的东西)。例如,阅读 NetSol 的常见问题解答:http: //www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/

if you want to BATCH EXPORT / DUMP to MySQL from MsAccess, you can create a FORM in access, put a button on it, and in VBA create this sub for the OnClick() event:

如果你想从 MsAccess 批量导出/转储到 MySQL,你可以在访问中创建一个 FORM,在它上面放一个按钮,然后在 VBA 中为 OnClick() 事件创建这个子:

Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=DSNname;UID=userOnServer;PWD=pwdOnServer"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST"
Resume SmoothExit_ExportTbls

sometimes, while running non-english windows you might get error 2507. change "ODBC Database" for "ODBC" (works with French).

有时,在运行非英语窗口时,您可能会收到错误 2507。将“ODBC 数据库”更改为“ODBC”(使用法语)。

IMPORTING: in MsAccess: 1. FILES 2. EXTERNAL DATA SOURCE 3. LINK TABLES

导入:在 MsAccess 中: 1. 文件 2. 外部数据源 3. 链接表

an MsAccess frontend doesnt really care what database engine it is using, so safe practice is to have 2 separate MDB's: queries, forms, macros, etc AND raw data. that way, you can seamlessly switch from using local database to remote server. and your core application file doesnt contain data proper.

MsAccess 前端并不真正关心它使用的是什么数据库引擎,因此安全的做法是拥有 2 个独立的 MDB:查询、表单、宏等和原始数据。这样,您就可以从使用本地数据库无缝切换到远程服务器。并且您的核心应用程序文件不包含正确的数据。