我正在尝试为我的Rails项目创建gitlab ci文件我.gitlab-ci.yml的一部分:
image: ruby:2.3.4
variables:
RAILS_ENV: test
services:
- mysql:5.7
before_script:
- apt-get update -qq && apt-get install -yqq nodejs libmysqlclient-dev
- ruby -v
- which ruby
- gem install bundler --no-ri --no-rdoc
- bundle install --jobs $(nproc) "${FLAGS[@]}"
- cp config/database.gitlab_ci.yml config/database.yml
- bundle exec rake db:create db:schema:load
- bundle exec rake db:migrate --quiet
我没能让它连接到我的MySql数据库。不管我做了什么。
这是我数据库的一部分
test: &test
adapter: mysql2
database: my_db
encoding: utf8
username: my_user
password: 1234
host: localhost
我总是犯这样的错误:
#<:error: can connect to local mysql server through socket>
Couldn't create database for {"adapter"=>"mysql2", "database"=>"my_db", "encoding"=>"utf8", "username"=>"my_db", "password"=>1234, "host"=>"localhost"}, {:charset=>"utf8"}
(If you set the charset manually, make sure you have a matching collation)
rake aborted!
Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
怎么解决?