linux postgresql 的安装

一、ubuntu

1、sudo apt-get install postgresql

2、sudo su postgres

3、更改密码(postgresql安装好后有个默认用户和默认数据库,名字都是postgres,我们需要先设置一个密码,然后才能连接)

  

4、连接

  psql -U postgres -d postgres -h 127.0.0.1 -p 5432

  需要指定用户名和将使用的数据,然后会提示输入密码,输入第3步更改的密码即可

二、centos

1、sudo yum -y install postgresql-server

2、sudo service postgresql initdb

3、 chkconfig postgresql on

4.

  

5、 sudo vim /var/lib/pgsql/data/pg_hba.conf

  红色框内之前是ident,全部改为trust(改为trus不需要密码,改为md5需要密码)

  

6、重启

sudo systemctl restart postgresql

7.连接

psql -U postgres -d postgres -h 127.0.0.1 -p 5432

 

posted @ 2017-10-05 15:24  lplucky  阅读(327)  评论(0编辑  收藏  举报