Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pipeline - How do I populating MySql database with .sql files in project ?

Thomas Eager
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 12, 2018 edited

How do I populating MySql database with .sql files in project ?

I have included Mysql as a service with the correct parameters for initialization in my pipeline.  I have included sql files to populate the database for unit tests.  I do not know the recommended way to get my scheme and data into the database.

I found that  I do not have the mysql client command line tool installed. 

1 answer

1 vote
Sasa Jovanovic March 27, 2018

You need to have mysql client installed first. Here's some example of my bitbucket-pipelines.yml

 

image: webdevops/php-apache:alpine

pipelines:
branches:
master:
- step:
script:
- apk update
- apk add mysql-client
- telnet 127.0.0.1 3306
- gunzip < drupal.sql.gz | mysql -u drupal -pdrupal -h 127.0.0.1 drupal
services:
- mysql
definitions:
services:
mysql:
image: mysql
environment:
MYSQL_DATABASE: 'drupal'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: 'drupal'
MYSQL_PASSWORD: 'drupal'

 

Command

telnet 127.0.0.1 3306

is here to check if mysql service is up (if it is not, this will throw error). Better solution is to use script from https://community.atlassian.com/t5/Bitbucket-discussions/Waiting-for-dependent-services-like-databases/td-p/615570 but it doesn't work for me always. 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events