1

I was able to install Craft using a Vagrant/Homestead setup, but I can't seem to connect to the database I want. I set up my hosts file to point to a '.dev' address while working locally on my machine.

My db.php file seems to be set up ok:

return [
  '*' => [
    'server' => 'localhost',
    'tablePrefix' => 'craft',
  ],
  '.dev' => [
    'database' => 'dev',
    'user' => 'homestead',
    'password' => 'secret',
  ],
  '.org' => [
    'database' => 'prod',
    'user' => 'root',
    'password' => '********',
  ],
];

When I ssh into my vagrant box and log into mysql, I can SHOW DATABASES and see:

+--------------------+
| information_schema |
| dev                |
| prod               |
| homestead          |
| mysql              |
| performance_schema |
+--------------------+

I'm overwriting the dev, prod and homestead databases with a backedup .sql file, however when I visit my local '.dev' address, my Craft site doesn't appear to carrying over any of those changes.

Is there a way to see which database Craft is actually connected to?

1

You could do something like this to at least see which environment from your multi-environment config that Craft is matching:

$craft = require 'path/to/craft/app/bootstrap.php';
echo $craft->config->get('server', ConfigFile::Db);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.