Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Help with pipeline error : "bash: mysql: command not found"

Sébastien Despont January 1, 2023

I am a new user of pipeline.

I really don't understand why I get the error "bash: mysql: command not found" with my pipeline script. The mysql client is well installed ?!

Is there someone to help me?

image: composer:2.0
definitions:
services:
mysql:
image: mysql:5.7
variables:
MYSQL_DATABASE: 'myDB'
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_USER: 'myUser'
MYSQL_PASSWORD: 'mypwd'

pipelines:
default:
- step:
name: InstallMySQL
script:
- apt-get update && apt-get install -y mysql-client
- mysql -h 127.0.0.1 -u myUser -pmypwd -e "SHOW DATABASES"
services:
- mysql

3 answers

1 accepted

0 votes
Answer accepted
Sébastien Despont January 2, 2023

For the records, I have managed to use mysql client in PHP images by installing mariadb-client like this:

 

 

image: php:8.0-apache
definitions:
services:
mysql:
image: mysql:5.7
variables:
MYSQL_DATABASE: 'myDB'
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_USER: 'myUser'
MYSQL_PASSWORD: 'mypwd'

pipelines:
default:
- step:
name: InstallMySQL
script:
- apt-get update && apt-get install -y mariadb-client
- mysql -h 127.0.0.1 -u myUser -pmypwd -e "SHOW DATABASES"
services:
- mysql

 

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 1, 2023

Welcome to the Atlassian Community!

This suggests that your build environment does not have a path defined that includes the directory that apt is installed in, or you are running it on a system that doesn't use apt for its package management.  (The "path" I mean here is the list of directories a process looks in for executables when asked to run something)

apt is usually installed in /usr/bin, and you will need to have admin rights to run it.

Sébastien Despont January 1, 2023

Thank you very much for your answer. OK I was using the default image suggested by Bitbucket pipeline creation interface for a PHP project, which doesn't permit to use APT apparently.

0 votes
Sébastien Despont January 1, 2023

In fact, the error comes from the installation command "bash: apt-get: command not found". But I don't understand how to fix this error.

 

Any idea?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events