Ubuntu 安装配置最新版 PostgreSQL
环境:Ubuntu Xenial (16.04) !!! CentOS 参考这里
#安装 PostgreSQL
sudo apt-get update
sudo apt-get upgrade
apt-get install htop wget software-properties-common
默认: sudo apt-get install postgresql (9.5版本)
For any Ubuntu version you need to can do this by the official PostgreSQL Apt Repository.
Ubuntu Xenial (16.04)
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
Ubuntu Trusty (14.04)sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
Ubuntu Precise (12.04)sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
# 配置 PostgreSQL
安装完成后,默认会:
(1)创建名为"postgres"的Linux用户
(2)创建名为"postgres"、不带密码的默认数据库账号作为数据库管理员
(3)创建名为"postgres"的表
默认配置信息:
Creating new cluster 9.6/main ...
config /etc/postgresql/9.6/main
data /var/lib/postgresql/9.6/main
locale en_US.UTF-8
socket /var/run/postgresql
port 5432
# PostgreSQL 命令
#查看版本
psql -- version
#切换用户
sudo -u postgres psql
#修改密码
ALTER USER postgres WITH ENCRYPTED PASSWORD 'XXX';
修改密码本地环境生效配置
#修改pg_hba.conf
#local all postgres peer
local all postgres md5
#重启服务
sudo service postgresql restart
#登陆
psql -U postgres
#修改Linux用户的密码
sudo passwd postgres
#配置数据库以允许远程连接访问
sudo vi /etc/postgresql/9.4/main/postgresql.conf
# 增加 listen_addresses = '*'
sudo vi /etc/postgresql/9.4/main/pg_hba.conf
#修改 IP4
#host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local all postgres peer # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
#host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
privilege
#重启服务
sudo service postgresql restart
sudo /etc/init.d/postgresql restart (reload)
\password:设置密码
\q:退出
\h:查看SQL命令的解释,比如\h select。
\?:查看psql命令列表。
\l:列出所有数据库。
\c [database_name]:连接其他数据库。
\d:列出当前数据库的所有表格。
\d [table_name]:列出某一张表格的结构。
\du:列出所有用户。
\e:打开文本编辑器。
\conninfo:列出当前数据库和连接的信息。
#防火墙
启用ufw: sudo ufw enable
防外对内访问:sudo ufw default deny
关闭:sudo ufw disable
状态:sudo ufw status
#查看TCP或者UDP端口使用情况
sudo netstat -anp
#某个端口的信息
sudo lsof -i :631
#查看Linux的端口使用情况
netstat -tln
#查看已经连接的服务端口(ESTABLISHED)
netstat -a
#查看所有的服务端口(LISTEN,ESTABLISHED)
sudo netstat -ap
REFER:
https://www.pgadmin.org/download/
MySQL、Postgres 开启远程访问权限(ubuntu)
http://wenzhixin.net.cn/2012/05/15/mysql_open_the_remote_access_ubuntu
Omnibus-GitLab 配置 PostgreSQL 开启远程访问
https://cong5.net/post/open-remote-connect-postgresql-with-omnibus-gitlab
Ubuntu 安装配置最新版 PostgreSQL的更多相关文章
- Ubuntu安装配置protobuf 2.5
Ubuntu安装配置protobuf 2.5 一.安装配置环境 Linux 1.安装protobuf 下载文件 https://github.com/protocolbuffers/protobuf/ ...
- [转载]Ubuntu安装配置 git 服务器和客户端
原文地址:Ubuntu安装配置 git 服务器和客户端作者:ding404 1.配置前准备 服务器:安装ssh server另外还装了gitosis做git的权限管理 sudo apt-get ins ...
- ubuntu 安装配置 JDK7和Android Studio(apt-get方式)
Ubuntu 安装配置JKD 7 $ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get ...
- 【Python+OpenCV】人脸识别基于环境Windows+Python3 version_3(Anaconda3)+OpenCV3.4.3安装配置最新版安装配置教程
注:本次安装因为我要安装的是win10(64bit)python3.7与OpenCV3.4.3教程(当下最新版,记录下时间2018-11-17),实际中这个教程的方法对于win10,32位又或是64位 ...
- Ubuntu 安装配置MySQL,并使用VS的Server Explorer UI界面远程管理MySQL
为安装配置方便,使用root账号登入Ubuntu. step1: 键入下面命令安装MySQL. 过程十分简单.安装过程中只需根据提示输入root账号的密码即可. step2:安装完成后检查MySQL是 ...
- 英文版Ubuntu安装配置搜狗拼音输入法
下载搜狗输入法 1 进入搜狗输入法官网,进入上面导航兰的 "输入法Linux版" 2 根据你安装的ubuntu是32位还是64位下载 END ubuntu安装搜狗输入法 1 进 ...
- UBuntu安装配置记录
记得是06年左右第一次安装的 Linux,当时是下载的 Fedora镜像,版本已经记不清了,在商业街的电脑维修店刻的盘,回来后兴冲冲地和XP一起安装的双系统.其实就是直接的体验了一把,只是看了看X-W ...
- Ubuntu安装配置Qt 4.86环境
安装 QT4.8.6库+QT Creator 2.4.1 下载地址公布 QT4.8.6库 http://mirrors.hustunique.com/qt/official_releases/qt/ ...
- Ubuntu安装配置Tensorflow-GPU
Ubuntu 16.04 + GTX 1080 Ti + CUDA 9.0 + Cudnn 7.1 安装配置 1. 安装显卡驱动 首先查看一下自己的电脑需要怎样的驱动,我们可以先到 http://ww ...
随机推荐
- Effective C++ 随笔(5)
条款27:尽量稍作转型动作 const_cast:常量性移除 dynamic_cast:安全向下转型 reinterpret_cast: static_cast: 如在子类当中享调用父类当中的某个方法 ...
- 防火墙内JVisualVM连接jstatd解决方案
jstatd启动后会打开两个端口,其中一个端口可通过参数“-p”指定,如果不指定默认为1099,另一个是一个随机端口,不能参数指定: # netstat -lpnt|grep jstatd tcp ...
- Django-配置、静态文件与路由
-----配置文件 1.BASE_DIR BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 2.DEBU ...
- Java中方法重写和方法重载
首先方法重写和方法重载是建立在Java的面向对象的继承和多态的特性基础上而出现的.至于面向对象的继承和多态的特性我就不在这里多说了.继承是指在一个父类的基础再创建一个子类,这样子类就拥有了父类的非私 ...
- hdu 2642 Stars 【二维树状数组】
题目 题目大意:Yifenfei是一个浪漫的人,他喜欢数天上的星星.为了使问题变得更容易,我们假设天空是一个二维平面,上面的星星有时会亮,有时会发暗.最开始,没有明亮的星星在天空中,然后将给出一些信息 ...
- zoj2607
题意:如左图,给定A,B,C,D的面积分别为大于等于a,b,c,d,求最小的面积 思路:因为a,b肯定有一个是满的(不然还可压缩到更小),同理,ac,bd,cd都只有一个是满的,所以有可能是对角满的, ...
- Android-okhttp下载网络图片并设置壁纸
在AndroidManifest.xml配置网络访问权限: <!-- 访问网络是危险的行为 所以需要权限 --> <uses-permission android:name=&quo ...
- Ubuntu 安装Sqldeveloper
linux下最好用的Oracle开发工具可能就是sqldeveloper了 首先在http://otn.oracle.com/ 上下载最新的Linux - sqldeveloper 我下载的时候版本是 ...
- 转MySQL遇到的语法差异及解决方案
最近公司项目需要从SQL Server转到MySQL, 在转的过程中遇到两者语法之间的一些差异,在网上找了解决方案后,特记录在此.由于解决方案可能有很多种,我只记录了自己使用过的,仅作参考. 1. 拼 ...
- ASP.NET自定义错误页并返回正确的500、404状态码
在项目中,我们常常需要自定义错误页面,但往往返回的状态码都变成了200,对SEO很不友好.我尝试过在百度上寻找解决方案,但找到的资料中说的方法都试过了,发现都是无法返回正确的状态码的. 最后,只好自已 ...