Sunday, November 23, 2014

beberapa perintah postgreSQL 9.3 di ubuntu 14.04

Setelbeah menggunakan postgresql 9.4 ternyata adabeberapa perintah yang berbeda. Setelah berhasil install postgre di ubuntu lalu masuk menggunakan perintah berikut

-------------------------------------------------
galih@galih-K46CA:~$ sudo su
[sudo] password for galih:
root@galih-K46CA:/home/galih# su - postgres
postgres@galih-K46CA:~$

------------------------------------------------

setelah masuk postgre selanjutnya membuat userbaru

--------------------------------------------
postgres@galih-K46CA:~$ createuser taqiemi
---------------------------------------------

Setelah user berhasil dibuat kita masuk menggunakan user postgre untuk memberi hak privellage, superuser, createdb dan lain2

------------------------------------------------------------------------------------
postgres@galih-K46CA:~$ psql -U postgres template1
psql (9.3.5)
Type "help" for help.

template1=#
template1=# ALTER USER taqiem superuser;
ALTER ROLE
template1=# ALTER USER taqiem createdb;
ALTER ROLE
template1=# \q
----------------------------------------------------------------------

 Selanjutnya login dengan user yang baru
----------------------------------------------------------------------
postgres@galih-K46CA:~$ psql -U taqiem template1
Password for user taqiem:
psql (9.3.5)
Type "help" for help.

template1=#
--------------------------------------------------------------------

Membuat database diuser baru
---------------------------------------------------------------------
template1=# create database monevdpu owner taqiem encoding 'SQL_ASCII' template template0;
CREATE DATABASE
---------------------------------------------------------------------

JIka mengalami error seperti ini
-------------------------------------------------------------------
ERROR:  encoding "SQL_ASCII" does not match locale "en_US.UTF-8"
DETAIL:  The chosen LC_CTYPE setting requires encoding "UTF8".
---------------------------------------------------------------------------------------------------------------

Maka dapat mengubah mengubah LC_CTYPE
--------------------------------------------------------------------------
ALTER DATABASE template0 SET LC_CTYPE TO 'C';
----------------------------------------------------------------------------------------



No comments:

Post a Comment