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.

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.

| improve this answer | |
  • 1
    That was it (sort of). I had multiple environments in the config file, but yiic needed something in the default (*) array. – jjmartucci Feb 12 '15 at 2:35
  • Ahh, yeah. There is no domain to match, so it needs something for the default. Nice catch. – Brad Bell Feb 12 '15 at 3:02
  • I still have this issue, any other ideas to try? – Luke Holder Mar 5 '15 at 11:18
  • @LukeHolder I'm out of ideas. Those are usually the 2 reasons I've seen it happen. – Brad Bell Mar 5 '15 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... – luwes Jun 15 '16 at 8:36

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.