Initialize PostgreSQL in CentOS7
1. Install epel;
Rpm-ivh http://mirrors.hustunique.com/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
Or
Yum install epel-release
2. Install postgresql;
Yum install postgresql *
3. initialize the database;
Postgresql-setup initdb
4. Start postgresql and set it to start automatically;
Systemctl restart sqlsystemctl enable postgresql
5. log on to the database to check the status. (Omitted)
Su-role spsql \ du (view role) \ l (list all databases) \ q (Exit)
6. Create roles (users in postgresql) and database instances;
Su-postgrescreateuser dbusercreatedb-e-O dbuser dbname
7. Set a password for a new user
Su-javasspsql \ password dbuser (enter the password twice) vim/var/lib/pgsql/data/pg_assist.conf
In/var/lib/pgsql/data/pg_cmd.conf, the default verification method is used.
Hostall all 127.0.0.1/32 ident
Change to password verification
Hostall all 127.0.0.1/32md5
8. Restart the database to make the new verification method take effect.
Systemctl restart postgresql
9. log on to the database as a new user;
Psql-U dbuser-d dbname-h 127.0.0.1 (enter the previous password)
10. Play (the following operations are performed on the postgresql Terminal)
\ Dp (View tables in the current database) create table test1 (t1 int, t2 varchar (20); \ dp \ d test1 (View table structure) select * from test1 limit 10; insert into test1 (t1, t2) values (11, 'ccccc '), (22, 'aaa'); select * from test1 limit 10; truncate table test1; select * from test1 limit 10; drop table test1; select * from test1 limit 10; \ dp