gitlab ci: mysql build and restore db dump

Viewed 3525

in gitlab.yml I have

mysql_build:
  stage: build
  variables:
    MYSQL_DATABASE: rates
    MYSQL_ROOT_PASSWORD: root
  services:
  - mysql:latest
  image: mysql
  before_script:
  - mysql --version
  script:
  - echo "SELECT 'OK';" | mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql "${MYSQL_DATABASE}"
  - mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" rates < db/rates_db.sql

it is install mysql successfully, but I want to restore sql dump file for accessing it in next stage.

when started this part, I have exception:

 - mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" rates < db/rates_db.sql

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

Real application located here

https://gitlab.com/armdev/exchange-rates

How can I restore db in mysql?

1 Answers
Related