root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS NAMES
28629657ea20 root_php "docker-php-entrypoi…" 7 months ago Up 7 mon
ths 0.0.0.0:80->80/tcp php
317d5321ba96 postgres:9.3 "docker-entrypoint.s…" 7 months ago Up 7 mon
ths 0.0.0.0:5432->5432/tcp pgsql
root@ubuntu:~# docker exec -it pgsql psql -U postgres -d postgres -c "DROP DATABASE evento_prd;"
psql: FATAL: role "postgres" does not exist
root@ubuntu:~# docker exec -it pgsql psql -U yogya -d postgres -c "DROP DATABASE evento_prd;"
DROP DATABASE
root@ubuntu:~# docker exec -it pgsql psql -U yogya -d postgres -c "CREATE DATABASE evento_prd;"
CREATE DATABASE
root@ubuntu:~# cd backup/
root@ubuntu:~/backup# docker exec -i pgsql psql -U yogya -d evento_prd < evento_prd-20200316_010001.sql
You cannot DROP and CREATE a database on the same command unfortunately, but you can run 2 separate commands
docker exec -it <container-id> psql -U <username> -d postgres -c "DROP DATABASE <dbname>;"
docker exec -it <container-id> psql -U <username> -d postgres -c "CREATE DATABASE <dbname>;"
Tidak ada komentar:
Posting Komentar