我从未使用过 Microsoft Access 数据库,但我经常从 Linux (Ubuntu) 服务器连接到 DB2(在 IBM AS/400 上)和 MS SQL 服务器。您的错误似乎表明您没有安装 MS Access 驱动程序 - 我唯一知道的是:http ://www.easysoft.com/products/data_access/odbc-access-driver/index.html
您的错误消息还显示“未找到数据源名称”——为了让我连接到 DB2 或 MSSQL,我必须向 /etc/odbc.ini 和 /etc/odbcinst.ini 添加一些信息。
/etc/odbcinst.ini - 这是您描述在哪里可以找到 ODBC 驱动程序的地方。下面是我用于 DB2 和 MSSQL 的示例:
[iseries]
Description = iSeries Access for Linux ODBC Driver
Driver = /usr/lib/libcwbodbc.so
Setup = /usr/lib/libcwbodbcs.so
NOTE1 = If using unixODBC 2.2.11 or later and you want the 32 and 64-bit ODBC drivers to share DSN's,
NOTE2 = the following Driver64/Setup64 keywords will provide that support.
Driver64 = /usr/lib/lib64/libcwbodbc.so
Setup64 = /usr/lib/lib64/libcwbodbcs.so
Threading = 2
DontDLClose = 1
UsageCount = 1
# Define where to find the driver for the Free TDS connections.
[freetds]
Description = MS SQL database access with Free TDS
Driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount = 1
[ODBC]
Trace = no
TraceFile = /tmp/odbc.log
在最后一部分([ODBC])中,我目前有 Trace = no - 如果您将其更改为 Trace = yes,您将在 /tmp/odbc.log 文件中获得一些有用的调试信息。
/etc/odbc.ini - 这是您定义数据源的地方。下面是我用于 DB2 和 MSSQL 的示例:
[primary]
Description = primary
Driver = iseries
System = XXX.XXX.XXX.XXX
UserID = XXXXXXXXXX
Password = XXXXXXXXXX
Naming = 0
DefaultLibraries = QGPL
Database = MYLIB
ConnectionType = 0
CommitMode = 2
ExtendedDynamic = 0
DefaultPkgLibrary = QGPL
DefaultPackage = A/DEFAULT(IBM),2,0,1,0,512
AllowDataCompression = 1
LibraryView = 0
AllowUnsupportedChar = 0
ForceTranslation = 0
Trace = 0
# Define a connection to the MSSQL server.
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[mssql]
Description = MSSQL Server
Driver = freetds
Database = MyDatabase
ServerName = mssql
TDS_Version = 8.0
我在 StackOverflow 上看到了很多关于在 Linux 机器上使用 MSFT Access 数据库的问题——而且似乎从来没有一个圆满的结局。如果有任何方法可以将数据移植到不同的、受更好支持的数据库系统(如 MySQL),我想你会省去一些麻烦。祝你好运!