【从零开始配置vps】07:postgresql.md 949 B


title: 【从零开始配置VPS】07:PostgreSQL tags: [] id: '2511' categories:

    • 从零开始配置VPS

      date: 2023-01-12 23:28:58

      version: '3.3'
      services:
      db:
      container_name: postgres-db
      environment:
          - TZ=Asia/Shanghai
          - POSTGRES_USER=root
          - POSTGRES_PASSWORD=ROOT_ACCESS_PASSWORD
      ports:
          - '5432:5432'
      volumes:
          - './pgdata:/var/lib/postgresql/data'
      image: postgres
      restart: unless-stopped
      
  • mkdir -p ~/db/PostgreSQL && cd ~/db/PostgreSQL && nano docker-compose.yml

  • sudo docker-compose up -d

  • sudo docker exec -it postgres-db psql

  • 使用命令 \q 退出psql

创建新数据库

  • create user ttrss with password 'ttrss_passwd'; #创建用户ttrss

  • CREATE DATABASE ttrss OWNER ttrss; #创建用户数据库

  • GRANT ALL PRIVILEGES ON DATABASE ttrss TO ttrss; #权限都赋予ttrss