How to execute mysql queries from command line

Just getting started here. I have tried several Docker images (php:7.1, composer) and specified a MySQL service:

services: 
  - mysql:5.7

However the “mysql” command is not installed in /usr/bin. I get:

mysql: command not found

Neither is apt-get installed, so installing doesn’t seem an easy option.

How do I execute any queries - e.g. create a database - on the MySQL service ? Do I need to connect to the mysql container and issue commands there somehow?

Duh. Have to use apk, not apt-get. So I can just install the mysql client:

before_script:
  - apk update
  - apk add mysql-client

And then remember to use --host=mysql as per https://docs.gitlab.com/ee/ci/docker/using_docker_images.html

1 Like