Mongodb Authentication failed

My composer.json


"yiisoft/yii2-mongodb": "~2.1"

Problem: Authentication failed

I rebuilt several roles for my Mongodb and assign them to Yii2-mongodb.

Before the previous step, it worked very well for a year.

And I used the updated username and password to maintain my website in local.

At first, it worked. However, it crashed after I changed my IP.

Surprisingly, when I create a new role with a new username and password, it works again.

I have no clue at all.




Additional information

System      : MacOS Sierra

Yii version : "~2.0.5",

PHP         : 7.0.24

MongoDB     : 3.4.7



Sincerely appreciate.

Does Mongodb save the IP with the user? That me be your problem

I solved the problem, but I do not know what’s going on. I address the process that I did in the past two days.

Firstly, I upgraded my Mac from Sierra to HighSierra, so I was not sure that would bother or not.

And then, I reinstalled my mac, because I thought install with apache may affect this or not.

All PHP packages were checked in php.ini and php7.1 was linked with httpd as well.

After that, I did all check. For example, I ran PHP for connecting to Mongodb in the script, ran Python for the double-check for PHP and ran my website.

However, it still failed. After that, I stopped the listening and restarted it. IT WORKED!

I guess maybe there is no need to reinstall HighSierra. All you need to do is to restart the listening like below in web folder.


php -S localhost

Thanks for helping!

Sincerely appreciate