2 回答

TA贡献1796条经验 获得超10个赞
localhost 不是 MySQL 服务器将侦听的主机;它是 MySQL 服务器所监听的主机。它将以 的名称提供mysql
。
此外,该命令env="root:rootroot@tcp(localhost:3306)/TESTDB"
在 shell 中设置一个局部变量。它不会影响环境变量。
设置环境变量
export
局部变量或者使用
variables
字典或专门为命令设置变量
go test
:
variables:
# Set your variable here for all jobs ...
env: root:rootroot@tcp(mysql:3306)/TESTDB
before_script:
# ... or export it here ...
- export env=root:rootroot@tcp(mysql:3306)/TESTDB
test:
services:
- mysql:5.7
variables:
# ... or set it here for this job only ...
env: root:rootroot@tcp(mysql:3306)/TESTDB
script:
# ... or set it here for the go command only
- env=root:rootroot@tcp(mysql:3306)/TESTDB go test ./...
- 2 回答
- 0 关注
- 204 浏览
添加回答
举报