Hey,
I am trying to load the schema.sql file into the mysql service but it seems that mysql is not ready at that time. i am not even sure if it's available since it's running on a separate docker as it seems.
What's the best solution for this to be able to load the sql schema?
Thank You.
image: edbizarro/bitbucket-pipelines-php7
pipelines:
default:
- step:
caches:
- composer
services:
- redis
- mysql
script:
- cp .env.build .env
- mysql -u root -proot -f avncms < database/schema/schema.sql
- composer install --no-interaction --no-progress --prefer-dist --no-scripts
- php artisan tools:deploy --no-interaction
- yarn
- vendor/bin/phpunit
definitions:
services:
redis:
image:
redis
mysql:
image:
mysql
environment:
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_DATABASE: 'avncms'
MYSQL_RANDOM_ROOT_PASSWORD: 'no'
MYSQL_USER: 'test_user'
MYSQL_PASSWORD: 'test_user_password'
Does the database exist on the docker prior to the import?
I don't think so but i am not sure how to check if it's available at the time it tries to import.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could add an extra step to ensure it is there prior to the import using the following syntax.
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
That would cover that possible problem, then we can see what happens next.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah it does not exist at that time.
+ mysql -u root -proot -e "CREATE DATABASE avncms"
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
It seems that the service is not ready or i can't access the mysql service from the build container.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try using the other mysql user you are creating (test_user) to check that mysql is available, it looks like root access to mysql is not going to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've just noticed in your above screenshot that you are running a version check on mysql, followed by a ps -ef.
It looks like you aren't seeing the mysql process running, so I would guess the version check is failing too.
I just built a quick pipeline test using a similar config file and don't see mysql started either.
Will check a bit more later on.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.