Menu

#635 Can't connect to local Mongo database - Adminer4.6.3 / PHP7.0 (w/mongodb PHP driver) / Mongo 3.2

Git
closed-works-for-me
nobody
mongo (2)
5
2019-11-11
2018-08-30
No

I have Latest Adminer (4.6.3) installed on Debian Stretch with PHP7.0 & Mongo 3.2 (installed from Debian repos). I am running with Nginx and PHP-FastCGI. I have installed the mongodb PHP driver (required for PHP7) via: pecl install mongodb. phpinfo reports: "MongoDB extension version 1.5.2".

When I try to connect to it via Adminer I get an error: Expected string for "password" URI option, null given. (Obviously I am including a password).

I tried installing the MongoDB PHP Library but that didn't change things (although perhaps I'm missing something?)

To confirm that it wasn't an issue with my Mongo setup itself, I tried a docker container dockette/adminer:full-php5 (which uses the old mongo PHP driver with PHP5.6). Using that I could connect to my MongoDB fine.

To see if something was amiss with my Adminer/PHP setup itself, I tried the "Official" Docker adminer:latest container (Adminer 4.6.3 in standalone config with fastcgi). That one doesn't come with the PHP mongodb driver, but following some instructions that I found here I installed the driver (FWIW somewhat similiar to what I'd used to install on Debian). After restarting that, I'm now getting a completely different error! Database does not support password.

Any insight would be appreciated.

Discussion

  • Jeremy Davis

    Jeremy Davis - 2018-08-30

    FWIW the maintainer of the docker-adminer container has noted that the Database does not support password. with MongoDB (using the mongodb PHP driver) is a current limititation of Adminer.

     
  • Jakub Vrána

    Jakub Vrána - 2018-09-18
    • status: open --> closed-works-for-me
     
  • Jakub Vrána

    Jakub Vrána - 2018-09-18

    This is what Adminer does:

    1. Connect with password.
    2. If it fails, report the error.
    3. If it succeeds, try to connect without the password.
    4. If it succeeds, report "Database does not support password." because otherwise anyone can connect to your database using Adminer.
    5. If it fails, continue normally.

    I don't see how "Expected string for "password" URI option, null given" can happen (if you are really passing a password). "Database does not support password" can happen if your Mongo doesn't support password. You can fix that by checking the password in Adminer::login and returning an empty password from Adminer::credentials.

     
    • Vojtěch Dušátko

      @jakubvrana Why these 2 lines? Mongo DB can be secured by login and password saved in some AuthDB.

      For example:
      When I'm connecting to mongo from bash I have to:

      • set database for authentication (command "use admin")
      • authenticate (command " db.auth("USERNAME","PASSWORD") ")
        ... only if auth success I can access to collections, etc.

      You can try it with these settings in /etc/mongo

      security:
        authorization: enabled
      
       

      Last edit: Vojtěch Dušátko 2019-09-20
      • Jakub Vrána

        Jakub Vrána - 2019-11-11

        The lines are there because the user might think that the database supports password but it actually doesn't. You can also try setting MONGO_AUTH_SOURCE which Adminer supports recently.

         
  • Marek

    Marek - 2019-04-11

    Adminer doesn't let you log in using credentials if it's also possible to log in without a password.

    As a workaround, I created a docker image which removes the additional check for the empty password. More info in the gist itself

    https://gist.github.com/cilf/017348bfbce87fb95ff61e295415a54f

     
  • Frantisek Hana

    Frantisek Hana - 2019-08-15

    I'm not sure if it's problem of Adminer or environment, but the described behaviour works on PHP5 for me and doesn't work on PHP7.

    The main problem is, that on PHP 7 connect with wrong credentials (empty pass, wrong pass, ...) doesn't throw exception.

    I also report it on Dockette

     

Log in to post a comment.

MongoDB Logo MongoDB