2014-02-24 00:19



I can not connect to MongoDb using PHP, the error I am getting is

Failed to connect to: Authentication failed on database 'abc' with username 'admin': auth fails

The code that I use to connect is:

try {
    $server = new Mongo("mongodb://admin:admin@");
} catch (Exception $e) {
    echo $e->getMessage();  

I have also installed RockMongo which can connect to the database fine.

The control panel that I am using is:, I have added port 27017 to the firewall via the control panel so it's passing trough.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongzhi6382 dongzhi6382 7年前

    So in a nutshell you seem to confusing the default credentials for you RockMongo UI with credentials to connect to MongoDB.

    By default on installation, MongoDB has no Authentication turned on. You can configure authentication if you so desire, and even add that configuration to your Rockmongo Setup so that it can work on a privileged user.

    All details are in the links provided.

    For now just connect as follows:


    Provided you have access from your or another machine.

    点赞 评论 复制链接分享