CircleCI:Mysql2 ::错误:无法在' 127.0.0.1'上连接到MySQL服务器(111)

时间:2017-10-04 02:32:56

标签: mysql ruby-on-rails ruby rspec circleci

将circleCI 1.0更新为2.0时无法解决错误。 我想用circleCI做什么非常简单,只需运行rspec测试。

错误是

Mysql2::Error: Can't connect to MySQL server on '127.0.0.1' (111)

我的.circleci / config.yml文件是

version: 2
jobs:
  build:
    docker:
      - image: circleci/ruby:2.1-node-browsers
        environment:
          RAILS_ENV: test
      - image: circleci/mysql:5.7
        environment:
          - MYSQL_USER=root
          - MYSQL_PASSWORD=''
    steps:
      - checkout

      # Restore bundle cache
      - restore_cache:
          key: rails-demo-{{ checksum "Gemfile.lock" }}

      # Bundle install dependencies
      - run: bundle install --path vendor/bundle

      # Store bundle cache
      - save_cache:
          key: rails-demo-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle

      # Database setup
      - run: mv config/database.yml.sample config/database.yml
      - run: RAILS_ENV=test bundle exec rake db:create
      - run: RAILS_ENV=test bundle exec rake db:schema:load

      # Run rspec in parallel
      - type: shell
        command: |
          bundle exec rspec --profile 10 \
                            --format RspecJunitFormatter \
                            --out test_results/rspec.xml \
                            --format progress \
                            $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)

      # Save test results for timing analysis
      - store_test_results:
          path: test_results

我的config / database.yml文件是

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

development:
  <<: *default
  database: app_development

test:
  <<: *default
  database: app_test

ruby​​版本是2.1.4,而mysql版本是5.7.10

0 个答案:

没有答案