1、docker pull postgres:13
2、docker run -d --name postgres13 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -v /home/sunyuhua/docker/postgresql/data:/var/lib/postgresql/data -v /etc/localtime:/etc/localtime --restart=always -p 15432:5432 postgres:13
3、 docker exec -it postgres13 /bin/bash
4、创建查询用户,并赋值权限
psql -U postgres
CREATE ROLE sa WITH SUPERUSER LOGIN PASSWORD ‘xxxxx’;
create user sa with password ‘xxxxxxx’;
grant all PRIVILEGES on database postgres to sa;
grant all PRIVILEGES on all tables in schema public TO sa;