mysql - 从 bitbucket 管道中的构建命令访问 mysql

标签 mysql docker continuous-integration bitbucket-pipelines

在我的 CI 过程中尝试执行 mysql 命令时,我收到 ERROR 2002 (HY000): Can't connect to local MySQL

这是我的 bitbucket-pipelines.yml 文件

image: theotherperson/php-ci:5.6

pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - apt-get update && apt-get install -y unzip mysql-client
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install --no-scripts --no-plugins
          - cp test-assets/vhosts/000-default.conf /etc/apache2/sites-enabled/000-default.conf
          - cp test-assets/hosts/hosts /etc/hosts
          - rm /var/www/html/index.html
          - cp -R $BITBUCKET_CLONE_DIR /var/www/html
          - service apache2 restart
          - mysql -u root -p$MYSQL_ROOT_PASSWORD -e "test < $BITBUCKET_CLONE_DIR/data/test/test.sql"
          - phantomjs --webdriver=4444 &
          - vendor/bin/behat -p test_behat
        services:
          - mysql

definitions:
  services:
    mysql:
      image: mysql
      environment:
        MYSQL_DATABASE: 'test'
        MYSQL_ROOT_PASSWORD: 'mypassword'

这里是错误:

+ mysql -u root -p$MYSQL_ROOT_PASSWORD -e "test < $BITBUCKET_CLONE_DIR/data/test/test.sql"
Enter password: ERROR 2002 (HY000): Can't connect to local MySQL

我需要做什么才能从这个命令行访问 mysql?

最佳答案

看看他们的documentation

Host name: 127.0.0.1 (avoid using localhost, as some clients will attempt to connect via a local "Unix socket", which will not work in Pipelines)

关于mysql - 从 bitbucket 管道中的构建命令访问 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49492441/

相关文章:

mysql - Doctrine ,多对多关系问题

php - 向 mySQL 表中插入数据

python - 如何针对其他环境运行 tox -e myenv?

git - TFS 2015 : How to exclude certain folders from triggering build with Git

mysql - 使用 codeigniter 从 mysql 检索图像

MYSQL:选择与多个表的多行相关的条目

python - MismatchingStateError:mismatching_state:CSRF警告!国家的请求和回应不平等

php - Dockerfile FROM vs Docker-compose IMAGE

docker - 在 Dockerfile 中运行 composer install

java - Azure 服务总线 - Java 应用程序的集成测试方法