2

我正在使用的服务为您提供了创建 docker-compose 文件的命令。然后您可以运行docker-compose up并选择创建一个新数据库。

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.8
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
volumes:
  mysql:

这可行,但现在我需要使用新数据库设置第二个项目。尽管我在运行项目时选择了设置新数据库的选项,但我可以看到它正在连接到我的旧数据库:

 prisma init
? Set up a new Prisma server or deploy to an existing server? Create new database
? What kind of database do you want to deploy to? MySQL

Created 3 new files:

  prisma.yml           Prisma service definition
  datamodel.graphql    GraphQL SDL-based datamodel (foundation for database)
  docker-compose.yml   Docker configuration file
Next steps:

  1. Start your Prisma server: docker-compose up -d
  2. Deploy your Prisma service: prisma deploy
  3. Read more about Prisma server:

我的 docker-compose.yml 中有什么东西不对吗?我相信default是数据库名称,所以我尝试了以下但同样的事情发生:

        databases:
          default2:
            connector: mysql
4

0 回答 0