在 MS Access 和 MySQL 之间同步数据的最佳方法是什么?

2021-12-12 00:00:00 ms-access database odbc mysql

我在 Windows 机器上有一个访问数据库,我必须将其导入到 linux 网络服务器上的 mysql.此时access dabatbase表导出为文本文件,用ftp自动复制,然后加载到mysql中.

I have an access database on a windows machine, which I must import into mysql on a linux webserver. At the moment the access dabatbase table is exported as a text file, automatically copied with ftp, and then loaded into mysql.

有没有更好的方法可以做到这一点,也许使用 ODBC 连接或其他方式?

Is there a better way to do this, perhaps using an ODBC connection or something else?

限制复制已经存在的信息的最佳方法是什么,即只传输在访问数据库中但尚未在 mysql 中的记录.

What is the best way to limit copying information that is already present, ie to only transfer records that are in the access database but not yet in the mysql one.

access 数据库是由另一个程序处理的,如果我不必对其进行更改,甚至不必打开它,那将是最好的.不可能需要从访问数据库中导入更新的记录.mysql 数据库将是主要来源,一些记录将被删除或更改.我只想导入从未在mysql数据库中的记录,而不是恢复故意删除的记录.

The access database is handled by another program, and it would be best if I did not have to makes changes to it, or even open it. There is no possibility of needing to import updated records from the access database. The mysql database will be the main source, and some records will be deleted or changed. I only want to import records that were never in the mysql database, not restore the ones that were purposefully deleted.

推荐答案

为什么不按照 Keltia 的建议通过 ODBC 链接表,然后使用一系列查询来添加丢失的记录并更新更改的记录.查询可以通过 VBA 运行.ADO 也可以很好地与 MySQL 和 Access 配合使用.

Why not link the tables through ODBC as suggested by Keltia, and then use a series of queries to add records that are missing and to update changed records. The queries can be run through VBA. ADO will also work well with MySQL and Access.

关于 Access 中使用的代码的一些说明:

Some notes on code used in Access:

   Set db = CurrentDb
   strSQL = "Insert INTO [ODBC;DSN=DSNName;].NameOfMySQLTable " _
   & "Select AnyField As NameOfMySQLField FROM AnyAccessTable;"

   db.Execute strSQL, dbFailOnError
   End Sub

-- http://forum.lessthandot.com/viewtopic.php?f=95&t=3862

相关文章