# << A Tour of PostgreSQL Internals >>
# 下载postgresql11.1
wget https://ftp.postgresql.org/pub/source/v11.1/postgresql-11.1.tar.gz
# 源码安装
tar zxvf postgresql-11.1.tar.gz
mv postgresql-11.1 /usr/local/pgsql
cd /usr/local/pgsql/
./configure --prefix=/usr/local/pgsql --without-readline --enable-debug
# 修改src/Makefile.global 删除优化选项
vim src/Makefile.global
# 编译
make
sudo make install
# 添加用户,设置目录权限
sudo adduser postgres
sudo passwd postgres
sudo mkdir -p /usr/local/pgsql/data
sudo chown -R postgres:root /usr/local/pgsql
# 设置环境变量
> su - postgres
> vim ~/.bash_profile
export PATH=$PATH:/usr/local/pgsql/bin
> source ~/.bash_profile
# 添加启动服务(确认文件postgresql内的目录正确)
cp /usr/local/pgsql/contrib/start-scripts/linux /etc/init.d/postgresql
chmod u+x /etc/init.d/postgresql
# 添加开启自启动
# chkconfig --add postgresql
systemctl enable postgresql
# 切换用户,初始化数据(确认data目录下为空)
su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
# 启动服务
# service postgresql start
systemctl start postgresql
# 创建测试库
createdb test
psql test
# 允许所有连接
> vim /usr/local/pgsql/data/pg_hba.conf
host all all 0.0.0.0/0 trust
# 侦听所有连接
> vim /usr/local/pgsql/data/postgresql.conf
listen_addresses = '*'
logging_collector = on
pgadmin4 安装:
#下载 pgadmin4 https://www.pgadmin.org/download/pgadmin-4-python-wheel/
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.1/pip/pgadmin4-4.1-py2.py3-none-any.whl
# 安装 pgadmin4
> pip install pgadmin4-2.0-py2.py3-none-any.whl
# 设置服务器地址
> vim /usr/lib/python2.7/site-packages/pgadmin4/config.py
DEFAULT_SERVER = '192.168.40.10'
# 设置邮箱用户&密码,启动服务
> python /usr/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
# 浏览器访问
http://192.168.40.10:5050/
ubuntu 1604源码安装postgresql11.1
最新推荐文章于 2024-09-05 10:30:00 发布