Gitlab ci configuration with mysql

Hi there,
I have some a repository on gitlab.com and I want to start use CI. To run my test env. I need a mysql database. I configure mysql as service on my stage but this doesn’t work. I got error below:

In AbstractMySQLDriver.php line 113: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 50: SQLSTATE[HY000] [2002] No such file or directory

and this is my configuration:

image: php:7.2

variables:
  PHP_MEMORY_LIMIT: "1024M"
  MYSQL_DATABASE: testdb
  MYSQL_ROOT_PASSWORD: secret

cache:
  paths:
    - vendor/

before_script:
  - apt-get update -yqq
  - apt-get install -yqq git libmcrypt-dev libpq-dev libcurl4-gnutls-dev libicu-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev
  - docker-php-ext-install mbstring pdo pdo_mysql mysqli curl json intl xml bz2 opcache pcntl
  - curl -sS https://getcomposer.org/installer | php
  - php composer.phar install
  - php bin/console migrations:migrate
  
stages:
  - test
acept:
  stage: test
  services:
    - mysql:5.7
  script:
    - cp config/parameters.yml.dist config/parameters.yml
    - cp tests/Resources/config/parameters.yml.dist tests/Resources/config/parameters.yml
    - php -d memory_limit=$PHP_MEMORY_LIMIT bin/behat --config behat.yml.dist

Regards!

My mistake I forgot to regenerate a container.

1 Like

Thanks Michal for taking the extra step of giving feedback on how you solved your issue. This will be really useful for any other community members who find themselves facing the same or a similar situation!

1 Like