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:


return [
    '.local' => [
        // The database server name or IP address. Usually this is 'localhost' or ''.
        'server' => '',

        // 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' => '',


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:


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.

  • 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
    Sep 21, 2016 at 22:01
  • I am running with craft.oerny.local (leads to 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
    Sep 22, 2016 at 7:40

3 Answers 3


You are using 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.

  • Hm... must have overread that part. Thank you anyway!
    – Björn K
    Sep 23, 2016 at 6:41

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

  • 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
    Sep 21, 2016 at 12:22
  • 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. craftcms.stackexchange.com/questions/999/… Sep 21, 2016 at 12:37
  • 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
    Sep 21, 2016 at 12:45

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.

Your Answer

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

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