Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection works via terminal mongo but not using Laravel-MongoDB #7

Closed
freak4pc opened this issue Jul 25, 2013 · 6 comments
Closed

Comments

@freak4pc
Copy link

Hey There,
Just installed Laravel-MongoDB on my Mongo setup,
After setting up everything in the database.php file I'm gettting a 'Failed to connect to: localhost:27017: Authentication failed on database 'vbtest' with username 'root': auth fails'

Even though I'm using exactly the same connection on the terminal which works.

Here's the Database.php config

'connections' => array(
                'mongodb'       => array(
                        'host'          => 'localhost',
                        'port'          => 27017,
                        'database'      => 'vbtest',
                        'username'      => 'root',
                        'password'      => 'mypassword'
                )
        ),

And this is how It works in the terminal

mongo --username=root --password=mypassword

Any ideas?
Thanks!
Shai.

@jenssegers
Copy link
Contributor

Are you able to connect to your server using the regular PHP client? http://www.php.net/manual/en/class.mongoclient.php

@freak4pc
Copy link
Author

Hey Jens,
Sorry it took 2 days to answer - Was away on vacation.

It does seem to work with a normal PHP client connection , e.g.

$mongo = new MongoClient('mongodb://root:mypassword@localhost/database');

@jenssegers
Copy link
Contributor

The library should generate the following connection string for your configuration (https://github.com/jenssegers/Laravel-MongoDB/blob/master/src/Jenssegers/Mongodb/Connection.php#L94):

mongodb://root:mypassword@localhost:27017/vbtest

@freak4pc
Copy link
Author

That is very interesting ... I'll check up a bit more on my end. I think you can close it and If i'll have any new findings I'll share them here. Thank you!

@mikeziri
Copy link

mikeziri commented Mar 4, 2014

I struggled with this for a whole day...
the problem was 'localhost' did'nt work. on my system it must be '127.0.0.1'

@L422Y
Copy link

L422Y commented Mar 16, 2015

I fixed this by installing mongo 1.6.5 driver with pecl upgrade mongo (running MongoDB 3.0)

alcaeus pushed a commit to alcaeus/laravel-mongodb that referenced this issue Aug 16, 2023
…th invalid direction (mongodb#7)

* Convert only strings, let the driver fail for int values
* Add more tests on Builder::orderBy
alcaeus pushed a commit that referenced this issue Aug 22, 2023
…th invalid direction (#7)

* Convert only strings, let the driver fail for int values
* Add more tests on Builder::orderBy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants