115 | | |
116 | | == Spatially-enable a database == |
| 115 | == Connecting to your new database == |
| 116 | |
| 117 | There are two primary ways to connect to your new database from the localhost, one is to use the pgadmin tool, the other is to use the psql command line tool. Remote connections via IP are left as exercises for the more advanced user. |
| 118 | |
| 119 | In either case, you'll need to connect to the database using your 'postgres' user account, which was created during installation of PostgreSQL. |
| 120 | What in the world is the password for this account? Who knows? I haven't been able to figure it out. Luckily, there are instructions on what to do at: https://help.ubuntu.com/community/PostgreSQL. |
| 121 | |
| 122 | An important distinction to make when getting started is that there are both a system user account named 'postgres' '''and''' a database account named 'postgres'. These are two separate accounts. The database allows psql-based command line connections from the localhost by system user accounts with the '''same username''' as the database account. Make sense? Bottom line is that you won't be able to do much at all until you set up the password for both of these accounts, separately. |
| 123 | |
| 124 | Note that some online documentation recommends setting up a system user account called 'postgres' with superuser privileges, but this is not a requirement for getting started. |
| 125 | |
| 126 | Next steps - start logged in as your user account |
| 127 | {{{ |
| 128 | $ sudo passwd postgres |
| 129 | Enter new UNIX password: |
| 130 | Retype new UNIX password: |
| 131 | passwd: password updated successfully |
| 132 | $ sudo -s -u postgres |
| 133 | postgres$ psql |
| 134 | psql (9.1.3) |
| 135 | Type "help" for help. |
| 136 | |
| 137 | postgres=# \password postgres |
| 138 | Enter new password: |
| 139 | Enter it again: |
| 140 | postgres=# \q |
| 141 | postgres$ |
| 142 | }}} |
| 143 | |
| 144 | If you're going to want to connect to the PostgreSQL database using your own account (so you don't have to fool around with 'postgres'), you may want to do this: |
| 145 | |
| 146 | {{{ |
| 147 | |
| 148 | }}} |
| 149 | |
| 150 | Now, you should be able to |
| 151 | |
| 152 | If you connect through pgadmin, use the following attributes: |
| 153 | * Name: this is an arbitrary name for your database server |
| 154 | * Host: localhost |
| 155 | * Port: 5432 [pre-filled as default] |
| 156 | * Service: [leave this blank] |
| 157 | * Maintenance DB: postgres [default] |
| 158 | * Username: postgres |
| 159 | * Password: whatever you set in the prior step |
| 160 | * Store password: uncheck this (or not, based on your security paranoia level) |
| 161 | * Colour: whatever suits your fancy |
| 162 | * Group: Servers [default] |
| 163 | |
| 164 | |
| 165 | |
| 166 | == Spatially-enabling a database == |