1. 程式人生 > 其它 >Pgql 資料庫登入、操作資料庫 、設定密碼、匯入資料、

Pgql 資料庫登入、操作資料庫 、設定密碼、匯入資料、

 

設定預設密碼

設定預設密碼
[root@VM_0_2_centos start-scripts]# su - postgres
Last login: Fri Nov 12 16:49:36 CST 2021 on pts/3
-bash-4.2$  psql -U postgres
psql (12.5)
Type "help" for help.

postgres=# ALTER USER postgres with encrypted password 'postgres'; 
ALTER ROLE
postgres=# 

 

匯入資料檔案

 

 

 

匯出資料:

[wiew@szyhdb1c ~
] cd /pgsoft/pg12.5/bin [view@szyhdblc bin] ./pg_dump -h 11.16.163.42 -p 5432 -U szsfs -d szsfs > /home/view/szsfs_db_2021/test_pd_dump_20211220/szsfs20211220.bak Password: [view@szyhdblc bin]

 

 

 

 

 

 

 

 

 

 

登入Pgsql 資料庫

To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Mon Mar 28 09:30:23 2022 from
192.168.255.4 [root@localhost home]# cd /usr/local/pgsql/bin/ [root@localhost bin]# ./psql -h 127.0.0.1 -p 5432 -U szsfs20220220 -d szsfs20220220 psql (12.5) Type "help" for help. szsfs20220220=#

 

 

 

[root@localhost bin]# clear
[root@localhost bin]# su - postgres
Last login: Mon Mar 28 10:02:24 CST 2022 on pts/
1 -bash-4.2$ -bash-4.2$ psql -U postgres psql (12.5) Type "help" for help. postgres=# \c szsfs20220220 You are now connected to database "szsfs20220220" as user "postgres". szsfs20220220=# \d t_paynote Table "public.t_paynote" Column | Type | Collation | Nullable | Default -----------------------+--------------------------------+-----------+----------+--------- pn_no | character varying(35) | | not null | unit_no | character varying(30) | | not null | unit_name | character varying(200) | | | payer_name | character varying(300) | | | payer_accountno | character varying(50) | | | receivable_amt | numeric(16,2) | | | pn_received_amt | numeric(16,2) | | | overdue_amt | numeric(16,2) | | | create_tm | timestamp(6) without time zone | | | paid_tm | timestamp(6) without time zone | | | rt_no | character varying(6) | | | receipt_no | character varying(20) | | | account_no | character varying(50) | | | bank_no | character varying(30) | | | bank_name | character varying(200) | | | st_type | numeric(10,0) | | | business_type | numeric(10,0) | | | status | numeric(10,0) | | | bind_status | numeric(10,0) | | | remark | character varying(200) | | | proctime | timestamp(6) without time zone | | | procuserid | numeric(10,0) | | | detailiteminfo | character varying(500) | | | fullcheckcode | character varying(5) | | | numcheckcode | character varying(5) | | | additionalamount | numeric(16,2) | | | paytype | numeric(10,0) | | | batchno | numeric(10,0) | | | acc_file_name | character varying(200) | | | wt_file_name | character varying(80) | | | acc_file_up_day | timestamp(6) without time zone | | | wt_file_down_day | timestamp(6) without time zone | | | payee_no | character varying(30) | | | payee_name | character varying(100) | | | id | numeric(20,0) | | not null | refund_bank_name | character varying(200) | | | refund_bank_no | character varying(30) | | |

 

 

 

 

 

 

 

 

 

 

設定預設密碼[root@VM_0_2_centos start-scripts]# su - postgresLast login: Fri Nov 12 16:49:36 CST 2021 on pts/3-bash-4.2$  psql -U postgrespsql (12.5)Type "help" for help.
postgres=# ALTER USER postgres with encrypted password 'postgres'; ALTER ROLEpostgres=# 




To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Mon Mar 28 09:30:23 2022 from 192.168.255.4 [root@localhost home]# cd /usr/local/pgsql/bin/[root@localhost bin]# ./psql -h 127.0.0.1 -p 5432 -U szsfs20220220 -d szsfs20220220psql (12.5)Type "help" for help.
 szsfs20220220=#  



[root@localhost bin]# clear[root@localhost bin]# su - postgresLast login: Mon Mar 28 10:02:24 CST 2022 on pts/1-bash-4.2$ -bash-4.2$ psql -U postgrespsql (12.5)Type "help" for help.
postgres=# \c szsfs20220220You are now connected to database "szsfs20220220" as user "postgres".szsfs20220220=# \d t_paynote                                Table "public.t_paynote"        Column         |              Type              | Collation | Nullable | Default -----------------------+--------------------------------+-----------+----------+--------- pn_no                 | character varying(35)          |           | not null |  unit_no               | character varying(30)          |           | not null |  unit_name             | character varying(200)         |           |          |  payer_name            | character varying(300)         |           |          |  payer_accountno       | character varying(50)          |           |          |  receivable_amt        | numeric(16,2)                  |           |          |  pn_received_amt       | numeric(16,2)                  |           |          |  overdue_amt           | numeric(16,2)                  |           |          |  create_tm             | timestamp(6) without time zone |           |          |  paid_tm               | timestamp(6) without time zone |           |          |  rt_no                 | character varying(6)           |           |          |  receipt_no            | character varying(20)          |           |          |  account_no            | character varying(50)          |           |          |  bank_no               | character varying(30)          |           |          |  bank_name             | character varying(200)         |           |          |  st_type               | numeric(10,0)                  |           |          |  business_type         | numeric(10,0)                  |           |          |  status                | numeric(10,0)                  |           |          |  bind_status           | numeric(10,0)                  |           |          |  remark                | character varying(200)         |           |          |  proctime              | timestamp(6) without time zone |           |          |  procuserid            | numeric(10,0)                  |           |          |  detailiteminfo        | character varying(500)         |           |          |  fullcheckcode         | character varying(5)           |           |          |  numcheckcode          | character varying(5)           |           |          |  additionalamount      | numeric(16,2)                  |           |          |  paytype               | numeric(10,0)                  |           |          |  batchno               | numeric(10,0)                  |           |          |  acc_file_name         | character varying(200)         |           |          |  wt_file_name          | character varying(80)          |           |          |  acc_file_up_day       | timestamp(6) without time zone |           |          |  wt_file_down_day      | timestamp(6) without time zone |           |          |  payee_no              | character varying(30)          |           |          |  payee_name            | character varying(100)         |           |          |  id                    | numeric(20,0)                  |           | not null |  refund_bank_name      | character varying(200)         |           |          |  refund_bank_no        | character varying(30)          |           |          |