小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

陳鋼的博客 CentOS7下初始化PostgreSQL

 lchjczw 2015-05-18

CentOS7下初始化PostgreSQL

2014 年 8 月 27 日

1、安裝epel;

1
rpm -ivh http://mirrors.hustunique.com/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm

或者

1
yum install epel-release

2、安裝postgresql;

1
yum install postgresql*

3、初始化數(shù)據(jù)庫;

1
postgresql-setup initdb

4、啟動postgresql并設置為開機自啟動;

1
2
systemctl restart postgresql
systemctl enable postgresql

5、登進數(shù)據(jù)庫看看狀態(tài);(可略)

1
2
3
4
5
su - postgres
psql
\du (查看角色)
\l (列出所有數(shù)據(jù)庫)
\q (退出)

6、創(chuàng)建角色(postgresql中的用戶)和數(shù)據(jù)庫實例;

1
2
3
su - postgres
createuser dbuser
createdb -e -O dbuser dbname

7、給新用戶設定密碼

1
2
3
4
su - postgres
psql
\password dbuser (輸入兩次密碼)
vim /var/lib/pgsql/data/pg_hba.conf

在/var/lib/pgsql/data/pg_hba.conf中,將默認驗證方法

1
host    all             all             127.0.0.1/32            ident

改為密碼驗證

1
host    all             all             127.0.0.1/32            md5

8、重啟數(shù)據(jù)庫,讓新的驗證方法生效

1
systemctl restart postgresql

9、新用戶登錄數(shù)據(jù)庫;

1
psql -U dbuser -d dbname -h 127.0.0.1 (輸入之前的密碼)

10、玩耍;(以下操作皆在postgresql終端中)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
\dp (查看當前庫中的表)
create table test1 (t1 int, t2 varchar(20));
\dp
\d test1 (查看表結(jié)構(gòu))
select * from test1 limit 10;
insert into test1 (t1,t2) values (11, 'ccccc'), (22, 'aaaa');
select * from test1 limit 10;
truncate table test1;
select * from test1 limit 10;
drop table test1;
select * from test1 limit 10;
\dp


    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多