PostgreSQL: Difference between revisions

From Han Wiki
Jump to navigation Jump to search
m →‎Initial set-up: adding of usage section
Line 1: Line 1:
= Initial set-up =
= Initial set-up =


Install and set-up (the default is v10.23 as of 2023-10-13)
Install (the default is v10.23 as of 2023-10-13)


{{testedon|RHEL 8.8 (Ootpa)|2023-10-13}}
{{testedon|RHEL 8.8 (Ootpa)|2023-10-13}}
Line 8: Line 8:
$ sudo yum module list | grep postgresql
$ sudo yum module list | grep postgresql
$ sudo yum install @postgresql
$ sudo yum install @postgresql
$ sudo postgresql-setup --initdb
</syntaxhighlight>
</syntaxhighlight>


Line 15: Line 14:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ sudo yum install @postgresql:9.6
$ sudo yum install @postgresql:9.6
</syntaxhighlight>
for the initial set-up
<syntaxhighlight lang="bash">
$ sudo postgresql-setup --initdb
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
</syntaxhighlight>
for setting up a password for the postgres account
<syntaxhighlight lang="bash">
$ sudo passwd postgres
Changing password for user postgres.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
</syntaxhighlight>
enable PostgreSQL server at the boot time
<syntaxhighlight lang="bash">
$ sudo systemctl enable postgresql
</syntaxhighlight>
= Prerequisite for psql console =
change to postgres user account
<syntaxhighlight lang="bash">
$ sudo -iu postgres
</syntaxhighlight>
log into postgres console
<syntaxhighlight lang="bash">
$ psql
psql (10.23)
Type "help" for help.
postgres=#
</syntaxhighlight>
= Usage =
{| class="wikitable sortable"
|+ PostgreSQL
|-
! Command !! Action !! Description or Notes
|-
| <code>\q</code> || Quit ||
|-
| Example || Example || Example
|-
| Example || Example || Example
|}
<code>\q</code>
<syntaxhighlight lang="bash">
</syntaxhighlight>
</syntaxhighlight>



Revision as of 12:51, 13 October 2023

Initial set-up

Install (the default is v10.23 as of 2023-10-13)

  • Last tested on 2023-10-13 (RHEL 8.8 (Ootpa))
$ sudo yum module list | grep postgresql
$ sudo yum install @postgresql

to install a specific version

$ sudo yum install @postgresql:9.6

for the initial set-up

$ sudo postgresql-setup --initdb
 * Initializing database in '/var/lib/pgsql/data'
 * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

for setting up a password for the postgres account

$ sudo passwd postgres
Changing password for user postgres.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

enable PostgreSQL server at the boot time

$ sudo systemctl enable postgresql


Prerequisite for psql console

change to postgres user account

$ sudo -iu postgres

log into postgres console

$ psql
psql (10.23)
Type "help" for help.

postgres=#


Usage

PostgreSQL
Command Action Description or Notes
\q Quit
Example Example Example
Example Example Example

\q

Resources

Introduction to PostgreSQL for MySQL Users