<p>You are using <a href="https://craftcms.com/docs/multi-environment-configs" rel="nofollow">multi-environment configs</a> improperly.</p>

<p>You <strong>must</strong> have an environment with the <code>*</code> key. This is how Craft knows that you are using a multi-environment config. Even if the value is simply an empty array, it must exist.</p>

<blockquote>
  <p>The <code>'*'</code> array is required to enable Craft’s multi-environment config support, even if you don’t need it. Craft specifically checks for it when deciding whether to enable multi-environment config support or not.</p>
</blockquote>

<p>And this is a bit of speculation... but I'd highly recommend having your <code>*</code> environment as the <em>first</em> item in the array. I'm not sure if it makes a difference to Craft, but it's at least a bit of a standard.</p>

CC BY-SA 3.0
2016-09-23T06:41:53.787Z
Hm... must have overread that part. Thank you anyway!
Björn K
CC BY-SA 3.0
2016-09-22T18:06:35.187Z
2016-09-22T18:06:35.187Z
Lindsey D
<p>Not sure, but maybe you can't have the table prefix as blank? <code>'tablePrefix' =&gt; ''</code> It needs to be something no?</p>

CC BY-SA 3.0
2016-09-21T12:22:16.723Z
I have already tried this, it still tries to use the default prefix. But that is not the issue, the Exception states that no database was selected, which is strange to me. I have even tried to use the default parameters (including creating the default database) but there was still no change.
Björn K
CC BY-SA 3.0
2016-09-21T12:37:40.143Z
I saw this, but the answer might not be satisfying as it's "try turning it off and on again" but it might lead you in the right direction. http://craftcms.stackexchange.com/questions/999/installation-error-1046-no-database-selected
AbbeyDesign
CC BY-SA 3.0
2016-09-21T12:45:31.310Z
If I were to use a virtual machine, I'd try this. But since I use my local machine without any virtual layer, this does not apply to me (especially since I tried it yesterday aswell and have restarted already between yesterday and today)
Björn K
CC BY-SA 3.0
2016-09-21T12:17:01.333Z
2016-09-21T12:17:01.333Z
AbbeyDesign
<p>Apparently the solution to my immediate problem is to remove the enviromental part of the database configuration, although it seemed to work for the general configuration just fine.</p>

<p>I am a little bit unsatisfied by this, however I can finally start playing around with craft.</p>

<p>If a solution for the bug with the environmental database configuration pops up, I'm as glad for it as the next guy.</p>

CC BY-SA 3.0
2016-09-22T13:54:42.033Z
2016-09-22T14:02:35.190Z
2016-09-22T14:02:35.190Z
Björn K
<p>I wanted to install a single instance of craft on my local machine. However upon starting the installation via calling <code>/admin/</code> or <code>/admin/install</code>, the only message I get, is</p>

<blockquote>
  <p>SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
  The SQL being executed was: SHOW TABLES LIKE 'craft_%'</p>
</blockquote>

<p>Which in itself is weird, since I have modified the configuration already to not use craft_ as a table prefix.</p>

<p>These are my settings:</p>

<ul>
<li>OS: Mac OS X 10.11.3 (El Capitan)</li>
<li>PHP 5.6.25</li>
<li>MySQL 5.7.14</li>
<li>Apache 2.4.16</li>
<li>Latest Craft 2 build from today / Latest Craft 3 build from today</li>
</ul>

<p>I have made the following changes to the configuration:</p>

<p><strong>craft/config/db.php</strong>:</p>

<pre><code>return [
    '.local' =&gt; [
        // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
        'server' =&gt; '127.0.0.1',

        // The database username to connect with.
        'user' =&gt; 'root',

        // The database password to connect with.
        'password' =&gt; '',

        // The name of the database to select.
        'database' =&gt; 'craft_cms',

        // The prefix to use when naming tables. This can be no more than 5 characters.
        'tablePrefix' =&gt; '',
    ],
];
</code></pre>

<p><strong>craft/config/general.php</strong>:</p>

<pre><code>return [
    '.local' =&gt; [
        'devMode' =&gt; true,
    ],
    '*' =&gt; [
        'omitScriptNameInUrls' =&gt; true,
    ],
];
</code></pre>

<p>I even went the extra mile and updated the my.cnf for mysql in order to work properly in 5.7:</p>

<pre><code>[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
</code></pre>

<p>Any suggestions?</p>

<p><strong>Edit</strong> Since the mods removed the craft3 tag due to my typo, I thought it was necessary to say that this error occurs on both the latest version of craft3 and craft2.</p>

CC BY-SA 3.0
2016-09-21T22:01:02.267Z
What's the domain you're accessing the install from? What happens if you remove the multi-environment part of db.php?  i.d. `'.local' => [`
Brad Bell
CC BY-SA 3.0
2016-09-22T07:40:04.407Z
I am running with **craft.oerny.local** (leads to 127.0.0.1 in my hosts file). Interestingly enough, without multi environment configuration, I get redirected towards the install page. But this is not the behaviour I was expecting, especially since I want to set up multiple environments. Is there a way?
Björn K
<install><craft3>
Local install does not start, PDO Exception
# Local install does not start, PDO Exception

(Asked by: username_0 on 2016-09-21)

I wanted to install a single instance of craft on my local machine. However upon starting the installation via calling /admin/ or /admin/install, the only message I get, is

SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
  The SQL being executed was: SHOW TABLES LIKE 'craft_%'

Which in itself is weird, since I have modified the configuration already to not use craft_ as a table prefix.
These are my settings:

OS: Mac OS X 10.11.3 (El Capitan)
PHP 5.6.25
MySQL 5.7.14
Apache 2.4.16
Latest Craft 2 build from today / Latest Craft 3 build from today

I have made the following changes to the configuration:
craft/config/db.php:
return [
    '.local' => [
        // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
        'server' => '127.0.0.1',

        // The database username to connect with.
        'user' => 'root',

        // The database password to connect with.
        'password' => '',

        // The name of the database to select.
        'database' => 'craft_cms',

        // The prefix to use when naming tables. This can be no more than 5 characters.
        'tablePrefix' => '',
    ],
];

craft/config/general.php:
return [
    '.local' => [
        'devMode' => true,
    ],
    '*' => [
        'omitScriptNameInUrls' => true,
    ],
];

I even went the extra mile and updated the my.cnf for mysql in order to work properly in 5.7:
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Any suggestions?
Edit Since the mods removed the craft3 tag due to my typo, I thought it was necessary to say that this error occurs on both the latest version of craft3 and craft2.

**Tags:** install, craft3

> **Comments:**
> **username_1**: What's the domain you're accessing the install from? What happens if you remove the multi-environment part of db.php?  i.d. `'.local' => [`  
> **username_0**: I am running with **craft.oerny.local** (leads to 127.0.0.1 in my hosts file). Interestingly enough, without multi environment configuration, I get redirected towards the install page. But this is not the behaviour I was expecting, especially since I want to set up multiple environments. Is there a way?  

---

## 3 answers

### Answer by username_2 on 2016-09-22. Score: 1 | Accepted answer

You are using [multi-environment configs](https://craftcms.com/docs/multi-environment-configs) improperly.

You **must** have an environment with the `*` key. This is how Craft knows that you are using a multi-environment config. Even if the value is simply an empty array, it must exist.

> The `'*'` array is required to enable Craft’s multi-environment config support, even if you don’t need it. Craft specifically checks for it when deciding whether to enable multi-environment config support or not.

And this is a bit of speculation... but I'd highly recommend having your `*` environment as the *first* item in the array. I'm not sure if it makes a difference to Craft, but it's at least a bit of a standard.

> **Comments:**
> **username_0**: Hm... must have overread that part. Thank you anyway!  

---

### Answer by username_3 on 2016-09-21. Score: 0

Not sure, but maybe you can't have the table prefix as blank? `'tablePrefix' => ''` It needs to be something no?

> **Comments:**
> **username_0**: I have already tried this, it still tries to use the default prefix. But that is not the issue, the Exception states that no database was selected, which is strange to me. I have even tried to use the default parameters (including creating the default database) but there was still no change.  
> **username_3**: I saw this, but the answer might not be satisfying as it's "try turning it off and on again" but it might lead you in the right direction. http://craftcms.stackexchange.com/questions/999/installation-error-1046-no-database-selected  
> **username_0**: If I were to use a virtual machine, I'd try this. But since I use my local machine without any virtual layer, this does not apply to me (especially since I tried it yesterday aswell and have restarted already between yesterday and today)  

---

### Answer by username_0 on 2016-09-22. Score: 0

Apparently the solution to my immediate problem is to remove the enviromental part of the database configuration, although it seemed to work for the general configuration just fine.

I am a little bit unsatisfied by this, however I can finally start playing around with craft.

If a solution for the bug with the environmental database configuration pops up, I'm as glad for it as the next guy.


---

