一、安装前准备工作

新建用户

sudo groupadd sql
sudo useradd -g sql postgres
sudo passwd postgres

创建数据及日志目录,并做相应授权

sudo mkdir -p /home/SQL/Data/pgsql/{data,log}
sudo chown -R postgres.sql /home/SQL/Data/pgsql/

注:可以添加一个软链接方便进入pgsql目录:ln -s /home/SQL/PostgreSQL/pgsql/ pgsql

二、进行数据库初始化

切换用户 postgres,并执行初始化操作

su postgres
cd /usr/local/pgsql/bin
./initdb -E utf8 -D /home/SQL/PostgreSQL/Data/data

初始化完成提示

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 locale "zh_CN.utf8".
initdb: could not find suitable text search configuration for locale "zh_CN.utf8"
The default text search configuration will be set to "simple". Data page checksums are disabled. fixing permissions on existing directory /home/SQL/PostgreSQL/Data/data ... ok
creating subdirectories ... ok
selecting default max_connections ...
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: ./pg_ctl -D /home/SQL/PostgreSQL/Data/data -l logfile start

三、安装后

配置环境变量,~/.bash_profile 添加如下内容

PATH=/usr/local/pgsql/bin:$PATH
export PATH

注:这个文件目录是在当前用户的根目录下,即/home/{User}/

四、启动 & 登陆

启动数据库

./pg_ctl -D /home/SQL/PostgreSQL/Data/data  -l /home/SQL/PostgreSQL/Data/log/postgres.log start

./postgres -D /home/SQL/PostgreSQL/Data/data > //home/SQL/PostgreSQL/Data/log/postgres.log &

登陆数据库

./psql

添加新用户和创建数据库

create user admin with password '××××××';
create database mydb with encoding='utf8' owner=admin;

验证登录

./psql -U admin -d mydb

退出并关闭数据库

创建表之后可以使用 \d 表名; 查看表的详细信息
使用 \l 查看当前的数据库列表
执行 \q 退出交互式界面
./pg_ctl -D /home/SQL/PostgreSQL/Data/data/ stop

连接远程数据库

-h参数指定服务器地址,默认为127.0.0.
-d指定连接之后选中的数据库,默认也是postgres
-U指定用户,默认是当前用户
-p 指定端口号,默认是"" 其它更多的参数选项可以执行:./psql --help 查看 {pgsql安装目录}/bin/psql -h {服务器IP} -d postgres -U postgres -p
如:
./psql -h 127.0.0.1 -d mydb -U postgres -p

PostgreSQL 二进制安装的更多相关文章

  1. PostgreSQL数据库安装Version10.5

    PostgreSQL数据库安装,基于版本10.5安装, 在Linux系统上使用*.gz二进制压缩包手动安装. 操作系统:Red Hat Enterprise Linux Server release ...

  2. ubuntu14.04下简易二进制安装mysql

    下载mysql-commnunity的5.6.24通用二进制版 tar解压 我安装到/opt目录,所以mv到/opt/ 可选,建了个软链 ln -s *** mysql 添加运行mysql服务的用户和 ...

  3. Mac 下 PostgreSQL 的安装与使用

    在 mac 下,可以利用 homebrew 直接安装 PostgreSQL: 1 brew install postgresql -v 稍等片刻,PostgreSQL 就安装完成.接下来就是初始数据库 ...

  4. Linux下的PostgreSQL简单安装手册

    1. 安装环境     linux版本: CentOS release 6.2 (Final)     pg版本    : postgresql-9.5.0   2. pg数据库下载地址 --http ...

  5. mysql5.6 通用二进制安装

    mysql5.6 通用二进制安装: #卸载原有的mysqlyum remove mysql*ls /etc/my.cnf*mv /etc/my.cnf* /tmp/ #安装依赖包yum install ...

  6. CentOS 6.3下PostgreSQL 的安装与配置

    一.简介 PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS),也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系统.有些特性甚至连商业数据库都不具备.这个起源于伯克 ...

  7. postgresql编译安装与调试(二)

    接前文postgresql编译安装与调试(一),继续说说postgresql的编译安装与调试. 上一篇已经详细说明了如何在Linux系统上编译安装postgresql,这次我们在此基础上简单讲讲如何在 ...

  8. [转] Mac 下 PostgreSQL 的安装与使用

    在 mac 下,可以利用 homebrew 直接安装 PostgreSQL: 1 brew install postgresql -v 稍等片刻,PostgreSQL 就安装完成.接下来就是初始数据库 ...

  9. CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方

    CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方 ...

随机推荐

  1. 使用jmeter做简单的压测(检查点、负载设置、聚合报告)

    1.添加断言(检查点) 在需要压测的接口下添加--断言--响应断言,取接口响应中包含有的数据即可 检查点HTTP请求-->断言-->响应断言1.名称.注释2.Apply to//作用于哪里 ...

  2. 有关nmap的5个常用的扫描指令

    [以下IP可替换成需要被测试的IP网段] 1.ping扫描:扫描192.168.0.0/24网段上有哪些主机是存活的: nmap -sP 192.168.0.0/24   2.端口扫描:扫描192.1 ...

  3. NSNotificationCenter的用法

    作用:NSNotificationCenter是专门供程序中不同类间的消息通信而设置的. 注册通知:即要在什么地方接受消息 [[NSNotificationCenter defaultCenter]  ...

  4. UVA - 11572 Unique Snowflakes 滑动扫描

    题目:点击打开题目链接 思路:从左往右扫描,定义扫描左端点L,右端点R,保证每次往几何中添加的都是符合要求的连续的数列中的元素,L和R从0扫到n,复杂度为O(n),使用set维护子数列,set查找删除 ...

  5. UML结构与解析——BUAA OO第四单元作业总结

    UML与解析架构 UML是什么 统一建模语言(英语:Unified Modeling Language,缩写 UML)是非专利的第三代建模和规约语言.UML是一种开放的方法,用于说明.可视化.构建和编 ...

  6. 关于dispatch_sync死锁问题

    首先,我们来看下下面一个例子: 代码:(串行队列里同步线程嵌套)     NSLog(@"haha");     dispatch_queue_t queue = dispatch ...

  7. Oralce重做日志(Redo Log)

    1.简介 Oracle引入重做日志的目的:数据库的恢复. Oracle相关进程:重做日志写进程(LGWR). 重做日志性质:联机日志文件,oracle服务器运行时需要管理它们. 相关数据字典:v$lo ...

  8. python基础补漏-07-正则表达式

    字符: .    匹配除了换行符以外的任意字符 \w  匹配字母或者数字或下划线或汉字(除了特殊字符外都能匹配) \s   匹配任意空白符 \d 匹配数字 \b 匹配单词的开始或者结束 ^ 匹配字符串 ...

  9. AutoEncoder and DenoiseAutoEncoder

    AutoEncoder and DenoiseAutoEncoder 第一部分 首先我们将实现一个如上图结构的最简单的AutoEncoder. 加载数据 在这里,我们使用MNIST手写数据集来进行实验 ...

  10. TOJ4277: Sequence 组合数学

    4277: Sequence Time Limit(Common/Java):2000MS/6000MS     Memory Limit:65536KByte Total Submit: 39   ...