2

So I have 3 mysql DB's defined in my database.php file. I had 2 for the longest time and everything worked fine. I have one titled mysql, one mysql1 and one mysql2. The first 2 work fine, I copied the second one, changed the name to mysql2 and added the proper parameters but it still always says "Database mysql1 not configured. Is there some sort of cache? or somewhere else I have to define it? I am calling the DB through a model like this.

protected $connection = 'mysql1';

This is my database.php for clarification

'mysql' => [
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => '',
    'username'  => '',
    'password'  => '',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
],
'mysql1' => [
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => '',
    'username'  => '',
    'password'  => '',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
],
'mysql2' => [
    'driver' => 'mysql',
    'host' => 'localhost',
    'port' => '3306',
    'database' => '',
    'username' => '',
    'password' => '',
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
],
3
  • you have multiple db servers, or you have one server with schemas whose names are mysql1, mysql2, etc...? Commented Jul 15, 2016 at 16:52
  • Multiple databases, same server. I have made an edit to the original post. Commented Jul 15, 2016 at 16:56
  • I had a similar problem with Database [mysql] not configured. If I ran php artisan cache:clear or config:cache I would get the same error. I solved it by going into laravel/bootstrap/cache and deleting the config.php file that was there, and then running the above commands again. I believe it was a file permission error that was preventing the cached config.php file from actually being cleared. Commented Nov 22, 2019 at 5:11

2 Answers 2

3

This was fixed by using the command

php artisan config:cache

I submitted a Laravel issue request to fix it since that absolutely should not be required to change the DB connections variable.

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

2 Comments

The only way this would have fixed the issue is if you had previously cached the config. If you don't want your config to be cached anymore, you can run php artisan config:clear, and this will remove the cached file for the config.
Worked for me, thanks! I edited many configs for the cookies, maybe composer install would've worked as well
1

If you can not delete cache with php artisan config:cache because it throws error after you run it:

[InvalidArgumentException]

Database [] not configured

And if you are sure that your connections parameters are good then try to manually delete bootstrap cache config files which are placed in app/bootstrap/cache folder.

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.