错误,用户'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/