Connect MLAB Mongo instance using mongosqld command
Lot’s of folk are wondering how to connect the MLAB mongo instance using mongosqld so they can connect it via ODBC to Power BI or Tableau. For the full tutorial, you can visit this link https://www.khanakia.com/mongodb-can-not-connect-the-database-by-mongodb-odbc-driver-windows/
This article only intends to connect the MLAB mongo instance via mongosqld command as usual command will not work with MLAB because mogosqld command tries to connect to admin DB which you don’t have permission to access if you are using mlab. So if you try to connect mlab instance via usual mongosqld query it will throw an error
error initializing schema: error listing databases: error listing databases: (Unauthorized) not authorized on admin to execute command
So in order to connect via mongosqld you need to generate the SCHEMA file beforehand and the define the schema file with mongosqld command so here are the steps:
Step1: Generate the Schema file
mongodrdl sample --db mydb --out D:\schema.drdl --host "ds261644.mlab.com" --port 61644 -u lucian -p pass123 --authenticationDatabase mydb
Step2: Connect via mongosqld
mongosqld --mongo-uri "mongodb://ds261644.mlab.com:61644" --schema D:\schema.drdl --auth -u lucian -p pass123 --mongo-authenticationSource mydb --defaultAuthSource mydb -v