| 76 | | |
| 77 | | |
| 78 | | == 資料庫 == |
| 79 | | |
| 80 | | === 資料庫列表 === |
| 81 | | |
| 82 | | {{{ |
| 83 | | ~$ sudo su - postgres |
| 84 | | ~$ psql |
| 85 | | postgres=# \l |
| 86 | | List of databases |
| 87 | | Name | Owner | Encoding | Collate | Ctype | Access privileges |
| 88 | | -----------+----------+----------+-------------+-------------+----------------------- |
| 89 | | postgres | postgres | UTF8 | zh_TW.UTF-8 | zh_TW.UTF-8 | |
| 90 | | template0 | postgres | UTF8 | zh_TW.UTF-8 | zh_TW.UTF-8 | =c/postgres + |
| 91 | | | | | | | postgres=CTc/postgres |
| 92 | | template1 | postgres | UTF8 | zh_TW.UTF-8 | zh_TW.UTF-8 | =c/postgres + |
| 93 | | | | | | | postgres=CTc/postgres |
| 94 | | (3 rows) |
| 95 | | |
| 96 | | }}} |
| 97 | | |
| 98 | | == 新增資料庫 == |
| 99 | | |
| 100 | | {{{ |
| 101 | | ~$ sudo su - postgres |
| 102 | | -bash-4.2$ createdb 資料庫名稱 |
| 103 | | }}} |
| 104 | | |
| 105 | | == 允許使用者可以管理指定資料庫 == |
| 106 | | |
| 107 | | {{{ |
| 108 | | ~$ sudo su - postgres |
| 109 | | -bash-4.2$ psql -d postgres ### 使用 postgres 資料庫 |
| 110 | | postgres=# ALTER USER 使用者名稱 WITH ENCRYPTED PASSWORD '密碼'; |
| 111 | | postgres=# GRANT ALL PRIVILEDGES ON DATABASE 資料庫名稱 TO 使用者名稱; |
| 112 | | }}} |
| 113 | | |
| 114 | | == 效能調校 == |
| | 76 | === 效能調校 === |
| 239 | | == 資料庫備份 == |
| | 201 | |
| | 202 | == 資料庫 == |
| | 203 | |
| | 204 | === 資料庫列表 === |
| | 205 | |
| | 206 | {{{ |
| | 207 | ~$ sudo su - postgres |
| | 208 | ~$ psql |
| | 209 | postgres=# \l |
| | 210 | List of databases |
| | 211 | Name | Owner | Encoding | Collate | Ctype | Access privileges |
| | 212 | -----------+----------+----------+-------------+-------------+----------------------- |
| | 213 | postgres | postgres | UTF8 | zh_TW.UTF-8 | zh_TW.UTF-8 | |
| | 214 | template0 | postgres | UTF8 | zh_TW.UTF-8 | zh_TW.UTF-8 | =c/postgres + |
| | 215 | | | | | | postgres=CTc/postgres |
| | 216 | template1 | postgres | UTF8 | zh_TW.UTF-8 | zh_TW.UTF-8 | =c/postgres + |
| | 217 | | | | | | postgres=CTc/postgres |
| | 218 | (3 rows) |
| | 219 | |
| | 220 | }}} |
| | 221 | |
| | 222 | == 新增資料庫 == |
| | 223 | |
| | 224 | {{{ |
| | 225 | ~$ sudo su - postgres |
| | 226 | -bash-4.2$ createdb 資料庫名稱 |
| | 227 | }}} |
| | 228 | |
| | 229 | == 允許使用者可以管理指定資料庫 == |
| | 230 | |
| | 231 | {{{ |
| | 232 | ~$ sudo su - postgres |
| | 233 | -bash-4.2$ psql -d postgres ### 使用 postgres 資料庫 |
| | 234 | postgres=# ALTER USER 使用者名稱 WITH ENCRYPTED PASSWORD '密碼'; |
| | 235 | postgres=# GRANT ALL PRIVILEDGES ON DATABASE 資料庫名稱 TO 使用者名稱; |
| | 236 | }}} |
| | 237 | |
| | 238 | === 資料庫備份 === |