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

How do I access mysql server via mysql service in pipelines? I'm stuck at "Access Denied"

pcsdev August 7, 2023

pipelines file (edited):

 

image: amazon/aws-cli

definitions:
  services:
    mysql:
      image: mysql:latest
      environment:
        MYSQL_DATABASE: $MYSQL_DATABASE
        MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
        MYSQL_USER: $MYSQL_USER
        MYSQL_PASSWORD: $MYSQL_PASSWORD

pipelines:
  branches:
    develop:
[...]
            - step:
          name: RUN IMAGE
          image:
            name: 1234567890.dkr.ecr.region.amazonaws.com/my-container:latest
            aws:
              access-key: $AWS_DEV_ACCESS_KEY
              secret-key: $AWS_DEV_SECRET_KEY
          services:
            - docker
            - mysql
          script:
            - apt update && apt install -y default-mysql-client
            - mysql -V
            - echo $MYSQL_USER
            - mysql -h 127.0.0.1 -u $MYSQL_USER -p $MYSQL_PASSWORD -e "SHOW DATABASES"
I get the following error with the show databases query:
Enter password: ERROR 1045 (28000): Access denied for user 'test_user'@'127.0.0.1' (using password: NO)

 

I have also tried with root user and the variable password as well as no password...

any ideas or insight appreciated.

thanks for reading.

 

edit1: I got this far from: https://community.atlassian.com/t5/Bitbucket-questions/How-do-I-use-MySQL-in-Bitbucket-Pipelines/qaq-p/461906  but it isnt the same issue...

1 answer

1 accepted

1 vote
Answer accepted
pcsdev August 7, 2023

there cant be ansy spaces between the flag and the password.

-p $MYSQL_PASSWORD

should be

-p$MYSQL_PASSWORD

Suggest an answer

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

Atlassian Community Events