简体   繁体   English

无法在位桶管道上连接到MySQL(111“连接被拒绝”)

[英]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.

相关问题 Mysql2::Error::ConnectionError: 无法在“mysql”上连接到 MySQL 服务器(111“连接被拒绝”) - Mysql2::Error::ConnectionError: Can't connect to MySQL server on 'mysql' (111 "Connection refused") 无法连接到'mysql.hostinger.in'上的MySQL服务器(111“连接被拒绝”) - Can't connect to MySQL server on 'mysql.hostinger.in' (111 “Connection refused”) Docker MYSQL [2003] 无法连接到 MySQL 服务器(111 连接被拒绝) - Docker MYSQL [2003] Can't connect to MySQL server (111 Connection refused) mysql.connector.errors.InterfaceError:2003:无法连接到“127.0.0.1:3306”上的 MySQL 服务器(111 连接被拒绝) - mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (111 Connection refused) 错误2003(HY000):无法连接到[IP]上的MySQL服务器(111“连接被拒绝”) - ERROR 2003 (HY000): Can't connect to MySQL server on [IP] (111 “Connection refused”) Mariadb docker容器无法使用Python连接到主机上的MySQL服务器(111连接被拒绝) - Mariadb docker container Can't connect to MySQL server on host (111 Connection refused) with Python 2003:无法连接到“192.168.0.14:3306”上的 MySQL 服务器(111 连接被拒绝) - 2003: Can't connect to MySQL server on '192.168.0.14:3306' (111 Connection refused) (pymysql.err.OperationalError)(2003,“无法连接到‘0.0.0.0’上的 MySQL 服务器([Errno 111] 连接被拒绝)”) - (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '0.0.0.0' ([Errno 111] Connection refused)") 错误2002(HY000):无法通过套接字'/opt/lampp/var/mysql/mysql.sock'连接到本地MySQL服务器(111“连接被拒绝”) - ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (111 “Connection refused”) Mysql:连接被拒绝错误:111 - Mysql: Connection refused ERROR: 111
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM