Hi,
Figured it out:
In my circl.yml
## Customize database setup
database:
override:
- mysql -u ubuntu -e "create database circle_test_account"
- mysql -u ubuntu -e "create database circle_test_fs"
- mysql -u ubuntu circle_test_account < test_account.sql
- mysql -u ubuntu circle_test_fs < test_fs.sql
Thanks
2 Likes
levlaz
December 29, 2015, 4:51am
2
Thank you for sharing this!
akahn
January 26, 2016, 3:05pm
3
Thank you for this. This should be added to the official documentation.
2 Likes
hadv
November 3, 2017, 6:42am
4
How to do the same things on CircleCI 2.0 with docker mysql image? I run command like CircleCI 1.0 but it report cannot connect as below
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
Exited with code 1
below is my config.yml
- run:
name: Initialize Database
command: |
mysql -u root -ppassword -e "create database if not exists testdb1 character set utf8mb4 collate utf8mb4_unicode_ci"
mysql -u root -ppassword -e "create database if not exists testdb2 character set utf8mb4 collate utf8mb4_unicode_ci"
php artisan migrate:refresh --no-interaction
php artisan db:seed
Read the readme of the MySQL Docker image you are using. Most of them use environment variables to setup an initial database.
Here’s the Docker Library MySQL image for example: https://hub.docker.com/_/mysql/
hadv
November 4, 2017, 4:10am
6
Okay, actually the problem is to create multiple database in CircleCI 2.0. Finally I come with two mysql docker images with different port.
1 Like
@hadv Could you share an example config file for that setup?
@skylinezum Could you share an example config.yml of this setup?
hadv
March 6, 2018, 3:18pm
9
Some things like below @esposito
version: 2
jobs:
build:
docker:
- image: php:7.0-apache
environment:
APP_ENV: testing
APP_DEBUG: true
APP_KEY: base64:H2lnWgQiH23t04sHcwDZ8VbLqQCD5J8hpVMdylqDkp0=
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: pet
DB_USERNAME: root
DB_PASSWORD: password
DB2_HOST: 127.0.0.1
DB2_PORT: 3307
DB2_DATABASE: platform
DB2_USERNAME: root
DB2_PASSWORD: password
DB3_HOST: 127.0.0.1
DB3_PORT: 3308
DB3_DATABASE: event
DB3_USERNAME: root
DB3_PASSWORD: password
CACHE_DRIVER: file
QUEUE_DRIVER: sync
- image: circleci/mysql:5.7
environment:
MYSQL_DATABASE: pet
MYSQL_ROOT_PASSWORD: password
- image: hadv/mysql:5.7
environment:
MYSQL_DATABASE: platform
MYSQL_ROOT_PASSWORD: password
- image: hadv/mysql3308:5.7
environment:
MYSQL_DATABASE: event
MYSQL_ROOT_PASSWORD: password
working_directory: /var/www/html
Hope this help!
1 Like