安装配置postgreSQL+pgcli+pgadmin3

记录了postgreSQL数据库的完整的安装配置过程,以及postgreSQL的pgcli命令行智能提醒扩展,pgadmin3图形化管理客户端的配置安装。此postgresql是bigsql版安装详情,另bigsql刚出新版9.6 www.bigsql.org

1.环境前提

  • linux(ubuntu16.04)
  • postgresql-95 在postgreSQL官网下载deb安装包

2.安装postgresql,使用dkpg命令进行安装

sudo dpkg -i /home/wxl/Downloads/postgresql-9.5.3-1-x64-bigsql.deb

3.配置并初始化postgreSQL 服务

3.1.开启服务

hwclock.sh              rc                     x11-common
wxl@wxl-pc:/etc/init.d$ sudo /etc/init.d/postgresql-95 start
PostgreSQL 9.5 Configuration
---------------------------------
This will initialize PostgreSQL database cluster. The following
questions will determine the database server port, superuser password
 and to start server on system boot. Press <ENTER> to accept defaults.

Specify PostgreSQL server port [5432]:
Specify superuser password [password]:
Do you want PostgreSQL server to be started on boot (y/n) [y]: n
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locales
  COLLATE:  en_US.UTF-8
  CTYPE:    en_US.UTF-8
  MESSAGES: en_US.UTF-8
  MONETARY: zh_CN.UTF-8
  NUMERIC:  zh_CN.UTF-8
  TIME:     zh_CN.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /opt/postgresql/pg95/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /opt/postgresql/pg95/data/base/1 ... ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    /opt/postgresql/pg95/bin/pg_ctl -D /opt/postgresql/pg95/data -l logfile start

Starting PostgreSQL 9.5:
waiting for server to start.... done
server started
PostgreSQL 9.5 started successfully
To load this postgres into your environment, source the env file:
. /opt/postgresql/pg95/pg95.env

3.2.配置系统变量,让postgreSQL环境变量生效

a.拷贝/opt/postgresql/pg95/pg95.env并重名为postgresql.sh,将postgreSQL.sh放置/etc/profile.d/下

wxl@wxl-pc: sudo cp /opt/postgresql/pg95/pg95.env /etc/profile.d/postgresql.sh

b.让变量生效

wxl@wxl-pc: source /etc/profile

3.3.进入postgresql 密码默认是password可以直接psql也可以psql -U postgres -d postgres进入sql

wxl@wxl-pc:~$ psql
Password:
psql (9.5.3)
Type "help" for help.

postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
postgres=# \q

3.4.修改默认密码(默认用户名是 postgres,密码是 postgres)

ALTER USER postgres WITH PASSWORD 'newpassword';
wxl@wxl-pc:~$ psql -U postgres -d postgres
Password for user postgres:
psql (9.5.3)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
ALTER ROLE
postgres=# \q

4.安装图形界面

4.1.快速安装安装pgcli

a.安装pip

wxl@wxl-pc:~$ sudo apt install python-pip

b.通过pip快速安装pgcli

wxl@wxl-pc:~$ sudo pip install pgcli

c.如果!!如下报错,因为没有写入路径的权限,加sudo

wxl@wxl-pc:~$ pip install pgcli
Collecting pgcli
  Using cached pgcli-1.1.0.tar.gz
Collecting pgspecial>=1.5.0 (from pgcli)
  Using cached pgspecial-1.5.0.tar.gz
Collecting click>=4.1 (from pgcli)
  Using cached click-6.6.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Pygments>=2.0 in /usr/local/lib/python2.7/dist-packages (from pgcli)
Requirement already satisfied (use --upgrade to upgrade): prompt_toolkit<1.1.0,>=1.0.0 in /usr/local/lib/python2.7/dist-packages (from pgcli)
Collecting psycopg2>=2.5.4 (from pgcli)
  Using cached psycopg2-2.6.2.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-sD12wU/psycopg2/

4.2.验证postgreSQL安装是否正确,并查看pgcli版本

a.开启postgreSQL

#开启postgreSQL
sudo /etc/init.d/postgresql-95 start
#环境变量生效
wxl@wxl-pc:~$ . /opt/postgresql/pg95/pg95.env

b.查看pgcli版本

wxl@wxl-pc:~$ pgcli
Password:
Version: 1.1.0
Chat: https://gitter.im/dbcli/pgcli
Mail: https://groups.google.com/forum/#!forum/pgcli
Home: http://pgcli.com
postgres>

5.安装pgadmin3可视化数据库管理工具

5.1.pgadmin3安装

wxl@wxl-pc:~$ sudo install pgadmin3

5.2.pdadmin3链接postgresql

正确填写信息 name,host,password等信息

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏沃趣科技

Oracle数据库性能障碍分析利器:SYSTEMSTATE DUMP介绍

作者 孟庆辉 沃趣科技数据库工程师 当数据库出现严重的性能问题或者hang了的时候,我们非常需要通过systemstate dump来知道进程在做什么,在等待...

37970
来自专栏我叫刘半仙

原荐记一次服务器被植入挖矿木马cpu飙升200%解决过程

线上服务器用的是某讯云的,欢快的完美运行着Tomcat,MySQL,MongoDB,ActiveMQ等程序。突然一则噩耗从前线传来:网站不能访问了。 此项目是我...

50340
来自专栏架构师之旅

expdp|impdp及exp|imp指令介绍

expdp介绍 EXPDP命令行选项 1. ATTACH 该选项用于在客户会话与已存在导出作用之间建立关联.语法如下 ATTACH=[schema_name.]...

31590
来自专栏Golang语言社区

Golang 语言调用动态库实现OpenGL及windows的API编程

最近晚上没有事情的时候,研究下了开源的walk-master源码,自己简单的分析了下,如果在 import ( "github.com/lxn/win...

361120
来自专栏北京马哥教育

一些Centos Python生产环境的部署命令

拿到一台干净的centos之后, 初始化Python环境, 一些命令和问题记录而已 可以搞成脚本自动初始化, 当然, 用docker更好 基础环境 1. 创建...

31940
来自专栏Seebug漏洞平台

使用 XML 内部实体绕过 Chrome 和 IE 的 XSS 过滤器

来源:BypassingXSSFiltersusingXMLInternalEntities 原作者:DavidLitchfield (david@davidl...

415100
来自专栏AILearning

Apache Zeppelin 中 JDBC通用 解释器

概述 JDBC解释器允许您无缝地创建到任何数据源的JDBC连接。 在运行每个语句后,将立即应用插入,更新和升级。 到目前为止,已经通过以下测试: ...

35570
来自专栏乐沙弥的世界

RMAN 配置、监控与管理

一个通道代表一个到设备(磁盘或磁带)的数据流并且在目标数据库或辅助数据库实例上产生一个相应的服务器会话(server session)

13110
来自专栏互联网杂技

SpringBoot ( 十二 ) :SpringBoot 如何测试打包部署

有很多网友会时不时的问我,spring boot项目如何测试,如何部署,在生产中有什么好的部署方案吗?这篇文章就来介绍一下spring boot 如何开发、调试...

10220
来自专栏沃趣科技

ASM 翻译系列第三十六弹:ACFS磁盘组的重平衡操作

原作者:Bane Radulovic 译者: 魏兴华 审核: 魏兴华 DBGeeK社区联合出品 原文链接:http://asmsupportguy....

375110

扫码关注云+社区

领取腾讯云代金券