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

<pre><code>$craft = require 'path/to/craft/app/bootstrap.php';
echo $craft-&gt;config-&gt;get('server', ConfigFile::Db);
</code></pre>

CC BY-SA 4.0
2022-08-11T20:39:54.990Z
This returns "Class 'ConfigFile' not found" for me.
Haydentech
CC BY-SA 3.0
2016-12-28T18:47:49.220Z
2016-12-28T18:47:49.220Z
Brad Bell
<p>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.</p>

<p>My <strong>db.php</strong> file seems to be set up ok:</p>

<pre><code>return [
  '*' =&gt; [
    'server' =&gt; 'localhost',
    'tablePrefix' =&gt; 'craft',
  ],
  '.dev' =&gt; [
    'database' =&gt; 'dev',
    'user' =&gt; 'homestead',
    'password' =&gt; 'secret',
  ],
  '.org' =&gt; [
    'database' =&gt; 'prod',
    'user' =&gt; 'root',
    'password' =&gt; '********',
  ],
];
</code></pre>

<p>When I ssh into my vagrant box and log into mysql, I can <code>SHOW DATABASES</code> and see:</p>

<pre><code>+--------------------+
| information_schema |
| dev                |
| prod               |
| homestead          |
| mysql              |
| performance_schema |
+--------------------+
</code></pre>

<p>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. </p>

<p>Is there a way to see which database Craft is actually connected to?</p>

<database>
How to see which database Craft is currently connected to?
# How to see which database Craft is currently connected to?

(Asked by: username_0 on 2016-12-28)

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?

**Tags:** database


---

## 1 answers

### Answer by username_1 on 2016-12-28. Score: 1 | Accepted answer

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);

> **Comments:**
> **username_2**: This returns "Class 'ConfigFile' not found" for me.  

---

