Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用CircleCI在Postgresql中添加其他数据库_Postgresql_Circleci_Circleci 2.0_Circleci Workflows - Fatal编程技术网

使用CircleCI在Postgresql中添加其他数据库

使用CircleCI在Postgresql中添加其他数据库,postgresql,circleci,circleci-2.0,circleci-workflows,Postgresql,Circleci,Circleci 2.0,Circleci Workflows,我的CircleCI构建有问题,我希望有人能帮我解决 我正在使用circleci/postgres图像,并为其提供postgres\u用户、postgres\u数据库和postgres\u密码环境值 - image: circleci/postgres:11.7 environment: POSTGRES_USER: postgres POSTGRES_DB: main POSTGRES_PASSWORD: secret 在我运行一些测试之后,我想创建一些额外的数据

我的CircleCI构建有问题,我希望有人能帮我解决

我正在使用
circleci/postgres
图像,并为其提供
postgres\u用户
postgres\u数据库
postgres\u密码
环境值

- image: circleci/postgres:11.7
  environment:
    POSTGRES_USER: postgres
    POSTGRES_DB: main
    POSTGRES_PASSWORD: secret
在我运行一些测试之后,我想创建一些额外的数据库,我就是这样做的

- run:
    name: "Creating Account Databases"
    command: |
      apk add postgresql-client
      createdb -h localhost temporary -O postgres
      createdb -h localhost temporaryother -O postgres
问题是当circle ci运行它时,我得到以下错误:

createdb: could not connect to database template1: FATAL:  role "root" does not exist

Exited with code exit status 1
CircleCI received exit code 1
我不确定如何解决这个问题,我没有在任何地方定义根角色,所以我不确定发生了什么


任何帮助都将不胜感激。

默认情况下,当您尝试创建时,当前用户将被视为数据库用户。您可能需要指定-U postgres来创建,但这可能需要密码。另一种方法是使用命令-sudo su postgres切换到用户postgres并执行createdb。默认情况下,当您尝试创建时,当前用户将作为数据库用户。您可能需要指定-U postgres来创建,但这可能需要密码。另一种方法是使用命令-sudosupostgres切换到用户postgres并执行createdb。