MySQL and Laravel 5.1, migrations failing

Hello, my build is currently failing on my master branch. This branch was just merged from develop, which succeded.

It fails at the migration:

php artisan migrate --force --env=production --no-interaction -vvv
[PDOException] SQLSTATE[HY000] [2002] No such file or directory

My circle.yml:

machine:
  timezone:
    America/Chicago

  php:
    version: 5.5.9

  environment:
    APP_ENV: testing
    DB_HOST: 127.0.0.1
    DB_DATABASE: circle_test
    DB_USERNAME: ubuntu

dependencies:
  override:
    - composer install --prefer-source --no-interaction
    - npm install
    - npm install -g bower
    - npm install -g gulp
    - bower install
    - gulp

  pre:
    - echo "memory_limit = 1024M" > ~/.phpenv/versions/5.5.9/etc/conf.d/memory.ini

  post:
    - php artisan optimize
    - sudo chmod -R 775 storage
    - sudo chmod -R 775 bootstrap/cache

test:
  post:
    - phpunit

database:
  override:
    - php artisan migrate --force --env=production --no-interaction -vvv
    - php artisan db:seed --force --env=production --no-interaction -vvv

If you SSH into the build and run the step manually do you get any additional logging?

No additional logging, same output.

Have you seen this? php - PDOException SQLSTATE[HY000] [2002] No such file or directory - Stack Overflow

Yes, running either with a forced env, or without causes the same error. What puzzles me, is that the database migrates correctly with the same env/files, on the develop branch.

What I’ve attempted so far:

  • DB_HOST as either localhost or 127.0.0.1
  • with or without a UNIX_SOCKET variable (/tmp/mysql.sock)
  • php artisan migrate with our without --env

Did you try rebuilding without cache? Have you force-pushed to the master branch recently?

Hello, I just tried rebuilding without cache without success. I did force-push into the branch, but the merge was not a forced push.

I would like to clear your source cache and see if that changes anything. Do you mind reaching out to sayhi@circleci.com referencing this post? I’ll get that done for you.

Okay, it was an error on my part, one of my migration file was trying to access another database, which of course didn’t exist. Thanks a lot for your time and help.

1 Like

Glad you were able to figure this out!