Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)



This is my circle file

version: 2
      - image: magroski/circle-webstack:0.5
      - image: circleci/mysql:5.6
          - MYSQL_ROOT_HOST=%
      - checkout
      - restore_cache:
          - v1-dependencies-{{ checksum "composer.json" }}
          - v1-dependencies-
      - run: composer install -n --prefer-dist
      - save_cache:
            - ./vendor
          key: v1-dependencies-{{ checksum "composer.json" }}
      - run:
          name: Install npm dependencies
          command: npm install
      - run:
          name: Compile js and css
          command: grunt
      - run: mkdir test-reports
      - run:
          name: Start Selenium
          command: java -jar /usr/local/bin/selenium.jar
          background: true
      - run: find db/ -name '*.sql' | awk '{ print "source",$0 }' | mysql -u ubuntu --batch circle_test
      - run: vendor/bin/codecept run -f --xml report.xml

And I’m getting “Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)” on the command “mysql -u ubuntu --batch circle_test”, I also tried “mysql --batch circle_test” and got the same result.

Also, my start selenium step is exiting with this message: “Step was canceled”

Any ideas how to fix those 2 issues?

EDIT: Bit more of info. I have mysql-client installed on my primary image. It’s basically an ubuntu 17:10 image with apache + php7.1 + phalcon. I can post a link to my Dockerfile if needed.


It’s possible that the db hasn’t started. Can you try the technique described here:

If that doesn’t help you can SSH into a build and try to connect to the mysql container from there where you can try different connection strings and check client versions etc.


Output from dockerize

2017/10/31 14:50:13 Waiting for host: localhost:3306
2017/10/31 14:50:13 Connected to tcp://localhost:3306

Output from mysql command

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

I will try ssh’ing to the build and debug from there.



mysql -h -u root circle_test


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.