Usually accessing to database is not recommended, but when developing a program we usually make an dummy database and access to the database directly.
So I am going to post some command which are helpful when you need to access the develop database directly.
1. you will be needing psql cmd to access the postgresql database, in mac book you can use the below command.
brew install postgresql
if you are using other kind of OS please check the below URL.
https://www.postgresql.org/download/
PostgreSQL: Downloads
www.postgresql.org
2. After you have installed the command line you just need to login to the database using the command line.
psql -h [HOSTNAME] -p [PORT] -d [DATABASE_NAME] -U [USERNAME]
3. Now you will probably entered the database now if you do not have any information just use the below command to list all the database.
\l
4. Now you know the databases just use the below command to list the tables.
\dt
5. if you want more information about tables detail use the below command.
\d [TABLE_NAME]
6. if you want to go out you can just use \q to quit.
7. And last but not least if you planning to dump the postgresql db you can use pg_dump
pg_dump -h [HOST] -p [PORT] -U [USERNAME] -d [DATABASE_NAME] -f [DUMPFILE_NAME]
The postgresql will require you to enter in the password.
8. And you can restore it easily by
psql -h [HOSTNAME] -p [PORT] -d [DATABASE] -U [USERNAME] -f [BACKUP_FILE_NAME]
now you have back up the postgresql database : )
it just for develop server, when you are tending to use production you should be using other stuffs.
'DevOps 잡다구리 > DevOps Tools' 카테고리의 다른 글
[ebpf] aya rust dropping packets 실습 및 설명 (0) | 2024.06.24 |
---|---|
[Devops] EKS auto scaling 하기 by cluster autoscaler (0) | 2024.04.23 |
WAL( Write Ahead Log ) Corruption ? (2) | 2023.11.25 |
Windows exporter 를 활용해서 특정 process up 유무 체크 하기. (0) | 2023.06.26 |