How can I open an ESRI Personal Geodatabase (*.mdb; ArcGIS 10.2) in QGIS 2.6 or above?
-
4Have you tried this and received an error or are you asking if there's an option available to open ESRI PGDB in QGIS 2.6? The option is available in Layer > Add Layer > Add Vector Layer > Database > select ESRI Personal GeoDatabase as Type– JosephJan 8, 2015 at 11:09
-
1Are you using 64 bit version of QGIS on Windows?– nmtokenMar 20, 2015 at 12:51
-
I've tried to do this but doesn't allow me to save the qgis.bat file with the changes. Any idea? Thanks– NandoSCSep 17, 2015 at 13:23
-
It can depend on the OS. The QGIS on Mac's gdal doesn't seem to do manage it.– Dave XMar 9 at 19:10
4 Answers
If you have installed a 64-bit version of QGIS on Windows and you find that Personal GeoDatabases (*.mdb) no longer work for you, then this solution might apply; I'm on QGIS 2.8.1 rather than 2.6, but I assume that the issue and thus the solution is the same.
The underlying issue relates to this GDAL bug: Problem reading MDBs (64-bit)
Step 1
Download the 64-bit version of the ODBC driver: Microsoft Access Database Engine 2010 Redistributable
If you don't have a 32-bit version of office installed you can just run the executable. If however you do have a 32-bit office installation you will need to run the executable from a command prompt using the /passive
option
Step 2
Locate the qgis.bat file (mine is in C:\OSGeo4W64\bin\qgis.bat
for example).
Add the following two lines:
set OGR_SKIP=ODBC
set PGEO_DRIVER_TEMPLATE=DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%%s
Step 3
Open QGIS and drag the mdb file onto your workspace
Voila!
-
1
Provided you have successfully installed Microsoft Access Database Engine 64 bit, you can:
Method 1 (works with QGIS 3)
In QGIS Settings panel -> Options | System | Environment add the following two variables:
variable name: OGR_SKIP
value: ODBC
variable name: PGEO_DRIVER_TEMPLATE
value: DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s
and check the "Use custom variables" checkbox
note that in this case there is only one percent sign in the value of PGEO_DRIVER_TEMPLATE
variable
Method 2 (works with both QGIS 2 and QGIS 3)
In the Environment Variables panel of the Windows Advanced System Settings, set the following two new variables as User Variables or System Variables:
variable name: OGR_SKIP
value: ODBC
variable name: PGEO_DRIVER_TEMPLATE
value: DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s
note that also in this case there is only one percent sign in the value of PGEO_DRIVER_TEMPLATE
variable
Method 3 (works with QGIS 2)
add the following two lines:
set OGR_SKIP=ODBC
set PGEO_DRIVER_TEMPLATE=DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%%s
in your qgis.bat / qgis-grass7.bat / qgis-ltr.bat / qgis-ltr-grass7.bat before the last line, that usually is something like
start "QGIS" /B "%OSGEO4W_ROOT%"\bin\qqis...
note that there are two percent signs in the value of PGEO_DRIVER_TEMPLATE
variable
The solution proposed works fine also on windows 10. Only a further suggestion for adding the two line to the qgis.bat file.
The two line are setting. So it is important to add the lines before the start of the command.
Probably it is undestood but if you are not careful, there is a risk of being mistaken.
-
Since this is the most recent answer I want to comment that it works but I can only get to load the feature classes (vector layer) but I do not see how to load the tables and relationships contained inside the mdb. Feature datasets are also ignored.– nanungaJun 14, 2018 at 0:44
In Debian and derivatives (may also work in Windows) with the latest QGIS (e.g. 3.16.11) and GDAL (e.g. 3.3.2) Personal Geodatabases (.mdb) could be added in three ways. However, ODBC and Geomedia
drivers must be skipped by GDAL/OGR via Settings>Options>GDAL>Vector Drivers
dialog:
Thereafter any of these approaches should work:
- drag and drop the file into the QGIS canvas
- expand the database file via Browser (Layer>Datasource Manager>Browser)
- as an ODBC database with a connection string:
create a ~/.odbc.ini
with:
[my_dataset]
Driver = Microsoft Access Driver (*.mdb)
Database = /path/to/my.mdb
create a ~/odbcinst.ini
if GDAL has not created it yet with:
[Microsoft Access Driver (*.mdb)]
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmdbodbc.so
FileUsage=1
UsageCount=50
in QGIS : Add Layer > Vector > Database > Type: Esri Personal Geodatabase > New