6

I've been trying to follow the docs for creating a plugin migration (https://craftcms.com/docs/plugins/migrations) but any attempts to run yiic seem to die with:

CDbConnection failed to open the DB connection. 

My Google-fu has not come up with any relevant answers. This is with Craft setup in a Vagrant box, if that makes a difference.

1
  • 1
    I've run into this as well when following this tutorial Commented Jun 17, 2015 at 2:59

1 Answer 1

2

If you're using 'localhost' for the 'server' in craft/config/db.php, try '127.0.0.1' and visa-versa.

For some reason, some environments are picky about that when connecting to MySQL from the CLI.

8
  • 1
    That was it (sort of). I had multiple environments in the config file, but yiic needed something in the default (*) array. Commented Feb 12, 2015 at 2:35
  • Ahh, yeah. There is no domain to match, so it needs something for the default. Nice catch. Commented Feb 12, 2015 at 3:02
  • I still have this issue, any other ideas to try? Commented Mar 5, 2015 at 11:18
  • @LukeHolder I'm out of ideas. Those are usually the 2 reasons I've seen it happen. Commented Mar 5, 2015 at 16:18
  • 1
    It seems you need every config line of your local environment in the default '*' => array(. So don't forget user, password and database... Commented Jun 15, 2016 at 8:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.