Author Topic: postgresql ออกจาก command line ยังไง \q+ Enter  (Read 4727 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
postgresql ออกจาก command line ยังไง \q+ Enter
« on: พฤษภาคม 22, 2016, 06:20:19 PM »
Type the following to exit the PostgreSQL command line utility psql:

\q + Enter

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: postgresql ออกจาก command line ยังไง \q+ Enter
« Reply #1 on: พฤษภาคม 22, 2016, 06:41:31 PM »
root@ubuntu:~# sudo su - postgres
postgres@ubuntu:~$ psql
psql (9.3.12)
Type "help" for help.

postgres=# \du
                              List of roles
 Role name  |                   Attributes                   | Member of
------------+------------------------------------------------+-----------
 odoo123       | Superuser, Create role, Create DB              | {}
 openx     |                                                | {}
 postgres123   | Superuser, Create role, Create DB, Replication | {}

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: postgresql ออกจาก command line ยังไง \q+ Enter
« Reply #2 on: พฤษภาคม 23, 2016, 09:35:54 AM »
Tip

Database

Without creating and configuring a PostgreSQL user for OpenERP as described below, you cannot create a database using OpenERP Client.

First Method

The default superuser for PostgreSQL is called postgres. You may need to login as this user first.

openerp@openerp-desktop:/$ sudo su postgres
password: XXXXXXXXXX
Now create PostgreSQL user openerp using the following command:

postgres@openerp-desktop:/$ createuser openerp
Shall the new role be a superuser? (y/n) y
Make this new user a superuser. Only then you can create a database using OpenERP Client. In short, openerp is the new user created in PostgreSQL for OpenERP. This user is the owner of all the tables created by OpenERP Client.

Now check the list of tables created in PostgreSQL using following command:

postgres@openerp-desktop:/$ psql -l
You can find the table template1, run the following command to use this table:

postgres@openerp-desktop:/$ psql template1
To apply access rights to the role openerp for the database which will be created from OpenERP Client, use the following command:

template1=# alter role openerp with password 'postgres';
ALTER ROLE
Second Method

Another option to create and configure a PostgreSQL user for OpenERP is shown below:

postgres@openerp-desktop:/$ createuser --createdb --username postgres --no-createrole
--pwprompt openerp
Enter password for new role: XXXXXXXXXX
Enter it again: XXXXXXXXXX
Shall the new role be a superuser? (y/n) y
CREATE ROLE
Note

Password

Note that the password is postgres.

Option explanations:

--createdb : the new user will be able to create new databases
--username postgres : createuser will use the postgres user (superuser)
--no-createrole : the new user will not be able to create new users
--pwprompt : createuser will ask you the new user's password
openerp : the new user's name

https://doc.odoo.com/install/linux/postgres/#setup-a-postgresql-user-for-openerp