PostgreSQL is an object-relational database system that has the features of traditional commercial database systems with enhancements to be found in next-generation DBMS systems.
Untuk menginstal PostgreSQL, jalankan perintah berikut dari terminal prompt:
sudo apt-get install postgresql
Setelah instalasi selesai, Anda dapat mengkonfigurasi server PostgreSQL sesuai dengan kebutuhan Anda, walaupun konfigurasi default-nya sudah mencukupi.
By default, connection via TCP/IP is disabled. PostgreSQL supports multiple client authentication methods. By default, IDENT authentication method is used. Please refer the PostgreSQL Administrator's Guide.
The following discussion assumes that you wish to enable
TCP/IP connections and use the MD5 method for client
authentication. PostgreSQL configuration files are stored in the
/etc/postgresql/<version>/main
directory. For example, if you install PostgreSQL 7.4, the
configuration files are stored in the
/etc/postgresql/7.4/main
directory.
![]() |
|
Untuk mengkonfigurasi autentifikasi ident, tambahkan entri ke berkas |
Untuk mengaktifkan koneksi TCP/IP, sunting berkas /etc/postgresql/7.4/main/postgresql.conf
Locate the line #tcpip_socket = false and change it to tcpip_socket = true. You may also edit all other parameters, if you know what you are doing! For details, refer to the configuration file or to the PostgreSQL documentation.
By default, the user credentials are not set for
MD5 client
authentication. So, first it is necessary to configure the PostgreSQL server to use
trust client
authentication, connect to the database,
configure the password, and revert the configuration back to use
MD5 client authentication.
To enable trust client
authentication, edit the file /etc/postgresql/7.4/main/pg_hba.conf
Comment out all the existing lines which use ident and MD5 client authentication and add the following line:
local all postgres trust sameuser
Kemudian, jalankan perintah berikut untuk menjalankan server PostgreSQL:
sudo /etc/init.d/postgresql start
Once the PostgreSQL server is successfully started, run the following command at a terminal prompt to connect to the default PostgreSQL template database
psql -U postgres -d template1
The above command connects to PostgreSQL database template1 as user postgres. Once you connect to the PostgreSQL server, you will be at a SQL prompt. You can run the following SQL command at the psql prompt to configure the password for the user postgres.
template1=# ALTER USER postgres with encrypted password 'your_password';
Setelah mengkonfigurasi kata sandi, sunting berkas /etc/postgresql/7.4/main/pg_hba.conf
untuk menggunakan autentifikasi MD5:
Komentari baris yang baru ditambah trust dan tambah baris berikut:
local all postgres md5 sameuser
![]() |
|
The above configuration is not complete by any means. Please refer the PostgreSQL Administrator's Guide to configure more parameters. |