Github操作: Using mysql service throws access denied for user 'root' @'localhost'

标签 github github-actions

错误,用户'root'@'localhost'的访问被拒绝(使用密码:是)
我正在尝试在Github Actions中使用mysql服务,但是没有运气。我收到以下错误

Access denied for user 'root'@'localhost' (using password: YES)



我的工作如下:
test:
  name: Test
  needs: install
  services:
    mysql:
      image: mysql:8.0
      ports:
        - '8888:3306'
      env:
        MYSQL_ROOT_PASSWORD: rootpass
        MYSQL_DATABASE: test
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@master
    - uses: actions/setup-node@master
      with:
        node-version: '10.x'
    - run: mysql --port 8888 -u root -prootpass -e 'CREATE DATABASE IF NOT EXISTS test;'

我似乎无法使其正常工作。任何帮助表示赞赏。可在以下位置找到针对我的测试设置的存储库的拉取请求:https://github.com/morsby/medmcq/pull/399

最佳答案

我花了一些时间尝试不同的方法来使它起作用。我找到了一个解决方案,但老实说,我不确定为什么会起作用。我只是将-h 127.0.0.1添加到mysql命令中。

我还向options添加了运行状况检查标志,以确保该服务能够接受请求。

这是一个工作流程:

name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    services:
      mysql:
        image: mysql:8.0
        env:
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: test
        ports:
            - '8888:3306'
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    steps:
      - uses: actions/checkout@v1
      - run: mysql -h 127.0.0.1 --port 8888 -u root -ppassword -e 'CREATE DATABASE IF NOT EXISTS test;'

关于Github操作: Using mysql service throws access denied for user 'root' @'localhost' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58222386/

相关文章:

windows - GitHub 操作拉取 Windows 图像

github-actions - GitHub 操作 : run if

git - 使用备用帐户在 GitHub 上共享项目

git - 如何在我的 git 服务器上获得类似 github 的 ssh 访问行为

github - travis ci构建错误

git - Webhook 和 CI/CD 之间的区别

github-actions - 如何通过 GitHub Actions 的 Pull Request 中的评论触发新作业

r - Github Actions如何在有注释时设置为失败?

git 分支删除 - HOOK

git - 在 Github 上,将 PR merge 到不同的分支