Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
本人是在deepin15.6下,编译安装PostgreSQL11beta2
Apps Section
975
views ·
1
replies ·
To
floor
Go
b***j@126.com
deepin
2018-07-29 06:42
Author
本人是在deepin15.6下,参考网上资料试着进行编译安装PostgreSQL11beta2的,已经走通了。贴出来给大家做个参考,节省点时间。
1、
准备工作
创建用户组
groupadd postgres
#创建用户
useradd -g postgres postgres
2、准备安装目录
#进入安装目录
cd /usr/local/
#删除原有安装(如果有的话)
rm -rf postgres*
3、
下载源码
#
获取压缩包
wget https://ftp.postgresql.org/pub/source/v11beta2/postgresql-11beta2.tar.bz2
#
解压
tar zxvf postgresql-11beta2.tar.bz2
4、编译安装
#配置
cd /home/zuoyh/Downloads/postgresql-11beta2
./configure --prefix=/usr/local/postgresql --without-readline
#编译安装
$su
#make && make install
#安装contrib目录下的一些工具,是第三方组织的一些工具代码,建议安装
#cd contrib
#make
# sudo make install
5、创建数据目录
#建postgres数据库的目录
#sudo mkdir -p /var/postgresql/data
#sudo chown postgres:postgres /var/postgresql -R
#sudo chown postgres:postgres /usr/local/postgresql -R
#chmod -R go-rwx /var/postgresql/data
6、添加环境变量
#为用户postgres设置密码
sudo passwd postgres
#切换用户
su root
#cd /home
#mkdir postgres
#cd postgres
su - postgres
在
~/.bash_profile的最后添加如下内容:
$sudo vi ~/.bash_profile
export PGHOME=/usr/local/postgresql
export PGDATA=/var/postgresql/data
export PATH=$PGHOME/bin
PATH
export MANPATH=$PGHOME/share/man
MANPATH
export LANG=en_US.utf8
export DATE=`date +"%Y-%m-%d %H:%M:%S"`
export LD_LIBRARY_PATH=$PGHOME/lib
LD_LIBRARY_PATH
alias rm='rm -i'
alias ll='ls -lh'
#alias pg_start='pg_ctl start -D $PGDATA'
#alias pg_stop='pg_ctl stop -D $PGDATA -m fast'
#初始化数据库
cd /usr/local/postgresql/bin
./initdb -D /var/postgresql/data
#启动服务
./pg_ctl -D /var/postgresql/data -l /var/postgresql/logfile start
7、
测试
#登录客户端使用"psql 数据库名"登录数据库。
#缺省数据库名时,连接到默认的数据库postgres。
#本地不用指定数据库
./psql
#创建测试数据库
create database test;
#切换到test 数据库
\c test
#创建测试表
create table test (id integer, name text);
#插入测试数据
insert into test values (1,'david');
#选择数据
select * from test ;
8、
其它配置
修改
linux 系统用户postgres 的密码
passwd postgres
修改
PostgresSQL 数据库配置实现远程访问
#修改postgresql.conf 文件
sudo vi /var/postgresql/data/postgresql.conf
9、
查看端口
cd /usr/local/postgresql/bin
#停止服务
./pg_ctl -D /var/postgresql/data -l /var/postgresql/logfile stop
#重启服务
./pg_ctl -D /var/postgresql/data -l /var/postgresql/logfile restart
#端口是否启用
$sudo netstat -anp | grep 5432
(有问题,请加QQ群161968030交流)
Reply
Like 0
Favorite
View the author
All Replies
b***j@126.com
deepin
2018-07-29 07:07
#1
使用sudo apt-get install postgresql默认安装的版本是9.6
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
【Enhanced Repo】Better Deepin Repo is released
Popular Events
More
cd /usr/local/postgresql/bin