0

I'm trying to connect to my MongoDB using MySQL through mongosqld. I have mongosqld running with a config file that looks like

security:
  enabled: true
mongodb:
  net:
    uri: test-db
    auth:
      username: usertest
      password: pass
      source: admin
schema:
    path: schema.drdl

I have it hosted on a mongo ODBC manager with SERVER=127.0.0.1, PORT=3071, DATABASE=test_db, UID=usertest?source=admin, PWD=pass. I am able to connect to and query this MongoDB through Excel using Mongo's tutorial for that, but I am not able to do the same with MySQL using Mongo's tutorial. When I try to connect from terminal with mysql 'user=usertest?source=admin' --default-auth=mongosql_auth -p I get ERROR 1045 (28000): Access denied for user 'usertest' andhandshake error: unable to saslStart conversation 0: Authentication failed.` from the mongosqld side. I am doing this on macOS. What could be causing this problem only for trying to connect from MySQL?

0

As per MongoDB documentation Connect from the MySQL Client You can use the command-line MySQL client to connect to the MongoDB Connector for BI.

Connect from MySQL without Authentication or TLS/SSL

To connect to a mongosqld instance listening on the MySQL default port 3307, run the following command:

mysql --protocol tcp --port 3307

Connect from MySQL with Authentication

Install the C Authentication Plugin as described in Install the C Authentication Plugin.

The following example uses the C authentication plugin to connect to a mongosqld instance listening on port 3307 as user reportsUser. The MySQL shell prompts for the password after the command has been entered.

mysql --user='reportsUser?source=admin' --default-auth=mongosql_auth -p

Note: This example assumes that the authentication plugin file mongosql_auth.so is located in the default MySQL plugin folder. The location of the plugin folder varies by platform, but you can locate it by running the following command:

mysql_config --plugindir

mysql_config.pl can find the plugin directory only on macOS and Linux hosts.

Important : The C Authentication plugin was developed against MySQL 5.7.18 Community Edition (64-bit), and tested with MySQL 5.7.18 Community Edition and the latest version of MongoDB Connector for BI. The plugin is not compatible with MySQL Server or Connector/ODBC driver version 8 and later.

Connect from MySQL with Authentication and TLS/SSL

To connect to a mongosqld instance listening on port 3307, as user grace using authentication mechanism PLAIN, and using specific TLS/SSL CA and x.509 certificates, run the following command:

mysql --enable-cleartext-plugin --protocol tcp --port 3307 \
  --user='grace?mechanism=PLAIN&source=$external' \
  --ssl-ca=/path_to_the_CAcert/ca.crt \
  --ssl-key=/path_to_my_certificate_key/mysql.key \
  --ssl-cert=/path_to_my_client_certificate/mysql.crt \
  -p

Important: The binary distribution of MySQL Community uses the yaSSL SSL library to encrypt connections. MySQL Enterprise uses OpenSSL which is compatible with MongoDB Connector for BI. Use MySQL Enterprise to connect to BI Connector over TLS / SSL.

If using the $external authentication source, wrap your username in single quotes or escape the $ character with a backslash to prevent your shell from performing interpolation.

For further your reference here

  • I said in my question that I already went through that tutorial and it did not work. – TheStrangeQuark Oct 9 '18 at 11:05
  • @TheStrangeQuark, Is it mysql ver 8.0.12 community edition or else? – Md Haidar Ali Khan Oct 9 '18 at 11:28
  • @TheStrangeQuark, Make sure that as per MongoDB documentation , the required port of MySQL Server . – Md Haidar Ali Khan Oct 9 '18 at 11:30
  • I figured it out, i was because I was on the wrong version of mysql. – TheStrangeQuark Oct 9 '18 at 11:32
  • @TheStrangeQuark, As initially i have reminded to MySQL Version as well as specific port . That's why again write down the MongoDB documentation with some important highlighted word. – Md Haidar Ali Khan Oct 9 '18 at 11:34
0

I found it was just the version of MySQL that I was using that was the problem. I was using MySQL version 8.0.12, but the documentation says

The C Authentication plugin was developed against MySQL 5.7.18 
Community Edition (64-bit), and tested with MySQL 5.7.18 Community 
Edition and the latest version of MongoDB Connector for BI. The 
plugin is not compatible with MySQL Server or Connector/ODBC driver 
version 8 and later.

Once I downloaded and used MySQL version 5.7, I was able to connect successfully.

  • I have already highlighted the MySQL version (5.7.18 ) in my answer. – Md Haidar Ali Khan Oct 9 '18 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.