0

I'm having a weird issue with Laravel where it is looking for the connection mysql when there is no connection called mysql. In my database.php config, I have the default connection set to:

'default' => env('DB_CONNECTION', 'permissions'),

and in my .env file, I have the line:

DB_CONNECTION=permissions

Here is the stack trace:

local.ERROR: InvalidArgumentException: Database [mysql] not configured. in D:\Development\Permissions\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:239
Stack trace:
#0 D:\Development\Permissions\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(158): Illuminate\Database\DatabaseManager->getConfig('mysql')
#1 D:\Development\Permissions\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(68): Illuminate\Database\DatabaseManager->makeConnection('mysql')
#2 D:\Development\Permissions\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(3348): Illuminate\Database\DatabaseManager->connection('mysql')
#3 D:\Development\Permissions\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(3314): Illuminate\Database\Eloquent\Model::resolveConnection(NULL)

I traced the issue to a call to vendor\laravel\framework\src\Illuminate\Database\DatabaseManager->getDefaultConnection(). For some reason even though the default connection is set to permissions, the connection name that returns is mysql. Here is the function for reference:

public function getDefaultConnection()
{
    return $this->app['config']['database.default'];
}

This issue is apearing on a Windows 10 box running ampps, but not an issue when running through homestead.

EDIT:

I can confirm that it is the 'default' => env('DB_CONNECTION', 'permissions'), line in the database.php file because when it is changed to be 'default' => 'permissions', the application works as expected.

4
  • Tried to empty your config cache? (php artisan config:clear) Commented Dec 29, 2016 at 18:52
  • I ran that command twice. Commented Dec 29, 2016 at 18:54
  • Alright. Have you setup your "permissions" connection? If yes, please show us the code. Commented Dec 29, 2016 at 18:57
  • 2
    Please see my edit. It is not an issue with the individual connections, but an issue with the DatabaseManager class retrieving the incorrect default connection name. Commented Dec 29, 2016 at 19:03

1 Answer 1

2

Please run the following commands.

To clear cache -

php artisan cache:clear

Clear config cache

php artisan config:clear

Then restart your laravel server. It should be working by now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.