MongoDB - Can not connect the database by Mongodb ODBC Driver Windows
Hello Friends,
So many users are complaining that they cannot connect to the Mongodb with the ODBC Driver so today I am gonna write this tutorial as I was also stuck with the MongoDB ODBC connector issue on windows and did not find any help over the internet. So after debugging lots of hours i finally able to connect with the MongoDB ODBC with my server. So, first of all, you need to download these prerequisites.
Step 1: Prerequisites
- Download and Install Community Server https://www.mongodb.com/download-center/community
- Download and Install https://www.mongodb.com/download-center/bi-connector
- Download and Install https://github.com/mongodb/mongo-odbc-driver/releases
- Go to Environment Variables and add these ones to the Path (Note: In my case server version is 4.0 and connector is 2.1 replace with yours)
- C:\Program Files\MongoDB\Server\4.0\bin
- C:\Program Files\MongoDB\Connector for BI\2.1\bin
Step 2: Connecting to Database via mongosqld
NOTE: You will have to connect to the MongoDB first via mongosqld only then you can proceed to the ODBC section. For MLAB: If you want to connect the Power BI via MLAB then skip STEP 2 and read this article https://www.khanakia.com/connect-mlab-mongo-instance-using-mongosqld-command/
Now create a mongosqld query you can read more about this here https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#bin.mongosqld
mongosqld --mongo-uri "mongodb://13.251.86.51:27017" --auth --mongo-username lucifer --mongo-password Pass1234 --mongo-authenticationSource admin
- Open Command Prompt and run the above query until it fully samples the whole schema and shows you all the collections names in the cli like this
Step 3: Connecting via ODBC
After that open ODBC Administrator and Create a System DSN you can read more here https://docs.mongodb.com/bi-connector/master/tutorial/create-system-dsn/
Now Test the connection. That’s all. 🙂