#Fedora 23
[acool@localhost ~]$ sudo dnf install postgresql-server.x86_64
[acool@localhost ~]$ sudo postgresql-setup --initdb
[acool@localhost ~]$ sudo systemctl start postgresql
[acool@localhost ~]$ sudo su - postgres
-bash-4.3$
-bash-4.3$
-bash-4.3$ createuser --pwprompt acool
Enter password for new role:
Enter it again:
-bash-4.3$
-bash-4.3$
-bash-4.3$ psql
psql (9.4.9)
Type "help" for help.
postgres=#
postgres=#
postgres=#
postgres-# # list databases
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres-#
postgres-# #list users (roles)
postgres-# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
acool | | {}
postgres | Superuser, Create role, Create DB, Replication | {}
postgres-#
postgres=#
postgres=# ALTER USER acool SUPERUSER;
ALTER ROLE
postgres=# ALTER USER acool CREATEROLE;
ALTER ROLE
postgres=# ALTER USER acool CREATEDB;
ALTER ROLE
postgres=# ALTER USER acool REPLICATION;
ALTER ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
acool | Superuser, Create role, Create DB, Replication | {}
postgres | Superuser, Create role, Create DB, Replication | {}
postgres=#
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ cat postgresql-test.sql
CREATE TABLE soccer_teams
(
name varchar(250),
city varchar(250)
);
[acool@localhost ~]$
[acool@localhost ~]$ createdb my-db-test
[acool@localhost ~]$
[acool@localhost ~]$ psql -d my-db-test
psql (9.4.9)
Type "help" for help.
my-db-test=#
my-db-test=#
my-db-test=# \i postgresql-test.sql
CREATE TABLE
my-db-test=#
my-db-test=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------+-------+-------
public | soccer_teams | table | acool
(1 row)
my-db-test=#
my-db-test-#
my-db-test-# \d+ soccer_teams
Table "public.soccer_teams"
Column | Type | Modifiers | Storage | Stats target | Description
--------+------------------------+-----------+----------+--------------+-------------
name | character varying(250) | | extended | |
city | character varying(250) | | extended | |
my-db-test=#
my-db-test=# INSERT INTO soccer_teams(name,city) VALUES('LA Galaxy','Los Angeles');
INSERT 0 1
my-db-test=#
my-db-test=# SELECT * FROM soccer_teams;
name | city
-----------+-------------
LA Galaxy | Los Angeles
(1 row)
my-db-test-#
my-db-test-# \q
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ psql -V
psql (PostgreSQL) 9.4.9
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$
// other crap
postgres=# #delete user (without roles?, DROP ROLE acool works too?, objects depend on it?)
postgres=# DROP USER acool;
DROP ROLE
[ view entry ] ( 1328 views ) | print article
<<First <Back | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Next> Last>>