[英]Can't connect to MySQL on bitbucket pipelines (111 “Connection refused”)
I try to connect to a database in my bitbucket pipeline and use the service definition as described in the docs , but I get the following error: 我尝试连接到我的Bitbucket管道中的数据库,并按照docs中的描述使用服务定义,但是出现以下错误:
+ mysql -h 127.0.0.1 -u root -ptest_user_password -e "SHOW DATABASES"
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")
Here's my bitbucket-pipelines.yaml
: 这是我的bitbucket-pipelines.yaml
:
image: debian:stretch
pipelines:
pull-requests:
'*':
- step:
script:
- apt-get update && apt-get install -y mysql-client
- mysql -h 127.0.0.1 -u root -ptest_user_password -e "SHOW DATABASES"
definitions:
services:
mysql:
image: mysql:5.7
variables:
MYSQL_DATABASE: 'pipelines'
MYSQL_ROOT_PASSWORD: 'test_user_password'
Any ideas what I am doing wrong? 有什么想法我做错了吗?
You forgot to tell your service to actually use the mysql service. 您忘了告诉您的服务实际使用mysql服务。 Try that config: 尝试该配置:
image: debian:stretch
pipelines:
pull-requests:
'*':
- step:
script:
- apt-get update && apt-get install -y mysql-client
- mysql -h 127.0.0.1 -u root -ptest_user_password -e "SHOW DATABASES"
services:
- mysql
definitions:
services:
mysql:
image: mysql:5.7
variables:
MYSQL_DATABASE: 'pipelines'
MYSQL_ROOT_PASSWORD: 'test_user_password'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.