diff --git a/Service%EF%BC%9AezBookkeeping.md b/Service%EF%BC%9AezBookkeeping.md index 96e1f00..b1a66eb 100644 --- a/Service%EF%BC%9AezBookkeeping.md +++ b/Service%EF%BC%9AezBookkeeping.md @@ -32,4 +32,31 @@ WantedBy=multi-user.target ```bash systemctl daemon-reload && systemctl enable ezbookkeeping.service && systemctl start ezbookkeeping.service && systemctl status ezbookkeeping.service +``` + +# 使用 + +```bash +sudo -u postgres psql +``` + +新建使用者與資料庫 + +```sql +CREATE USER ezbookkeeping WITH PASSWORD 'ezbookkeeping'; + +CREATE DATABASE ezbookkeeping; +``` + +設定資料庫權限 + +```sql +-- 1. Give ownership of the database to the app user +ALTER DATABASE ezbookkeeping OWNER TO ezbookkeeping; + +-- 2. Give ownership of the public schema to the app user +ALTER SCHEMA public OWNER TO ezbookkeeping; + +-- 3. Ensure the user has create permissions (Crucial for Postgres 15+) +GRANT USAGE, CREATE ON SCHEMA public TO ezbookkeeping; ``` \ No newline at end of file