Laravel-mongodb: Database [mongodb] not configured.

Created on 11 Jun 2015  Â·  4Comments  Â·  Source: jenssegers/laravel-mongodb

Hello,

I have installed it with Laravel 5.1 and got error during sign up Database [mongodb] not configured., but when i tried to connect to Mongo from routes
$connection = new MongoClient("mongodb://user:pass@localhost/db"); print_r($connection);
its working...
Whats my problem and how to solve it ?

Thanks

Most helpful comment

Just rebuild your config cache:
artisan config:cache

(leave the mongodb connection inside your connections array, as it is supposed to be).

All 4 comments

Have you put the configuration under the connections key in config/database.php

'mongodb' => array(
    'driver'   => 'mongodb',
    'host'     => 'localhost',
    'port'     => 27017,
    'username' => 'username',
    'password' => 'password',
    'database' => 'database',
    'options' => array(
        'db' => 'admin' // sets the authentication database required by mongo 3
    )
),

If so, try: dd(DB::connection('mongodb')->collection('potato')->get()); It should return []. _Note: ensure …connection( [THIS KEY] )->… matches the connection config key._

I had this problem at first, because I had a typo in my model's protected $connection attribute.

Just rebuild your config cache:
artisan config:cache

(leave the mongodb connection inside your connections array, as it is supposed to be).

Just got this issue, andresenra's answer did the trick for me.

I did but it couldn't
artisan config:cache

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lgt picture lgt  Â·  3Comments

ricardofontanelli picture ricardofontanelli  Â·  3Comments

BlakeGardner picture BlakeGardner  Â·  3Comments

bastiendonjon picture bastiendonjon  Â·  3Comments

kschethan picture kschethan  Â·  3Comments