mysql - 无法在 bitbucket 管道上连接到 MySQL(111“连接被拒绝”)
问题描述
我尝试连接到我的 bitbucket 管道中的数据库并使用文档中描述的服务定义,但出现以下错误:
+ 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")
这是我的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'
任何想法我做错了什么?
解决方案
您忘记告诉您的服务实际使用 mysql 服务。试试那个配置:
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'
推荐阅读
- android - 如何在不按返回按钮和关闭按钮的情况下将数据从第二个活动传递到第一个(弹出窗口)?
- gitlab - 发布到组的 gitlab pypi 包注册表
- python - 如何将带有 pip 文件的文件夹配置为本地 pip 存储库
- elixir - 如何更新与 Ecto 的多对多关联
- user-interface - Extjs 布局项目的顺序混乱
- firebase-storage - 在 Flutter Web 上使用 firebase_storage 4.0.0 将图像上传到 Firebase 存储?
- clickhouse - 如何计算每个用户每天的点数,以及从开始到当天在 clickhouse 中的所有点
- python - Python Flask 使用 curl 返回视频文件或 JSON 数据
- python-3.x - 如何在同步函数中调用异步函数?
- c# - Visual Studio 未找到所有引用