Skip to content

1. 创建库和用户

sql
create user transuser with password 'transiff61384e';

create database taoism_translation owner transuser;
grant all privileges on database taoism_translation to transuser;
create user transuser with password 'transiff61384e';

create database taoism_translation owner transuser;
grant all privileges on database taoism_translation to transuser;

2. 授权

sql
-- 1. 创建用户(如果还没创建)
CREATE USER transuser WITH PASSWORD 'transiff61384e';

-- 2. 创建数据库(如果还没创建)
CREATE DATABASE taoism_translation WITH OWNER transuser;

-- 3. 撤销用户对public schema的权限(可选,增加安全性)
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM public;

-- 4. 授予用户连接权限
GRANT CONNECT ON DATABASE taoism_translation TO transuser;

-- 5. 授予用户对数据库中表的权限
\c taoism_translation
GRANT USAGE ON SCHEMA public TO transuser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO transuser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO transuser;

-- 6. 撤销对其他数据库的访问权限(如果有)
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM transuser;
-- 1. 创建用户(如果还没创建)
CREATE USER transuser WITH PASSWORD 'transiff61384e';

-- 2. 创建数据库(如果还没创建)
CREATE DATABASE taoism_translation WITH OWNER transuser;

-- 3. 撤销用户对public schema的权限(可选,增加安全性)
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM public;

-- 4. 授予用户连接权限
GRANT CONNECT ON DATABASE taoism_translation TO transuser;

-- 5. 授予用户对数据库中表的权限
\c taoism_translation
GRANT USAGE ON SCHEMA public TO transuser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO transuser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO transuser;

-- 6. 撤销对其他数据库的访问权限(如果有)
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM transuser;

3. 备份

sql
pg_dump -U postgres -h 127.0.0.1 -p 5532 -d fllowordersystem  --no-owner --no-tablespaces --no-privileges >fll.sql

pg_dump -U postgres -h 127.0.0.1 -p 5532  -t fllowordersetting fllowordersystem  --no-owner --no-tablespaces --no-privileges >fllowordersetting.sql
pg_dump -U postgres -h 127.0.0.1 -p 5532 -d fllowordersystem  --no-owner --no-tablespaces --no-privileges >fll.sql

pg_dump -U postgres -h 127.0.0.1 -p 5532  -t fllowordersetting fllowordersystem  --no-owner --no-tablespaces --no-privileges >fllowordersetting.sql