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.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.