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

mysql
php7.1

#1

This is my circle file

version: 2
jobs:
  build:
    docker:
      - image: magroski/circle-webstack:0.5
      - image: circleci/mysql:5.6
        environment:
          - MYSQL_ALLOW_EMPTY_PASSWORD=true
          - MYSQL_ROOT_HOST=%
    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "composer.json" }}
          - v1-dependencies-
      - run: composer install -n --prefer-dist
      - save_cache:
          paths:
            - ./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.


#2

It’s possible that the db hasn’t started. Can you try the technique described here: https://circleci.com/docs/2.0/postgres-config/#using-dockerize

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.


#3

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.


#4

Fixed!

mysql -h 127.0.0.1 -u root circle_test


#5

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