Mysql command not found

docker
mysql
circle.yml

#1

Hi I am using CircleCI 2.0. I am wondering how do I get access to the mysql shell if I am using mysql in a container? I am currently getting the error mysql: command not found.

mysql --version
Shell: /bin/bash -eo pipefail

/bin/bash: mysql: command not found
Exited with code 127

#config.yml
version: 2
jobs:
build:
docker:
- image: node:6.9.5
- image: mysql:5.6.34
environment:
PRODUCTION_USERNAME: test
MYSQL_ALLOW_EMPTY_PASSWORD: yes
working_directory: ~/app
steps:
- checkout
- run:
name: Install Dependencies
command: npm install
- run:
name: Run tests
command: mysql --version

I would eventually like to run the sql below using the mysql command

echo "Creating $DB_USER db user"
echo “GRANT USAGE ON . TO ‘$DB_USER’@’%’;DROP USER ‘$DB_USER’@’%’;CREATE USER ‘$DB_USER’@’%’ IDENTIFIED BY ‘$DB_PASS’;GRANT ALL PRIVILEGES ON . TO ‘$DB_USER’@’%’ WITH GRANT OPTION;” | mysql -uroot -h localhost
echo “GRANT USAGE ON . TO ‘$DB_USER’@‘localhost’;DROP USER ‘$DB_USER’@‘localhost’;CREATE USER ‘$DB_USER’@‘localhost’ IDENTIFIED BY ‘$DB_PASS’;GRANT ALL PRIVILEGES ON . TO ‘$DB_USER’@‘localhost’ WITH GRANT OPTION;” | mysql -uroot -h localhost


#2

Thing is that only first container on a list forms a base which has all its binaries available. This means that from second and all following containers you expected only to use EXPOSE-d ports.

In other words, if you need mysql, you need to install mysql client into your base (node) image. Say, you can create your own image, which is FROM library/node:latest and has mysql client installed.


#3