我從來沒有與合作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])我現在有跟蹤= NO - 如果你改變,要跟蹤= 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
我在這裏看到了一些問題,在計算器上談論使用MSFT Access數據庫從一臺Linux機器 - 而且似乎沒有永遠一個圓滿的結局。如果有任何方法可以將數據移植到不同的,更好支持的數據庫系統(如MySQL),我認爲您可以節省一些頭痛的問題。祝你好運!
用於連接上述語法上的最新版本不工作別人有問題 - 而不是使用 '$文件名=「/path/to/database.mdb」;'' $ PDO =新PDO( 「ODBC:DRIVER = {斯軟件ODBC-ACCESS}; MDBFILE = {$文件名};」);' 注意,驅動程序和MDBFILE都擋帽,和DBQ現在是MDBFILE – Kev
嗨,事實上,它的工作原理與斯軟件ODBC-ACCESS驅動程序。但它不是免費的,而且相當昂貴。你知道任何用於Linux的ODBC訪問驅動程序,而不是MDB工具(SQL支持非常有限)嗎? – Franck
發現一個很好的替代商業ODBC訪問驅動程序:mdb-SQLite https://code.google.com/p/mdb-sqlite/ – Franck