Ubuntu14.04安装PostpreSQL9.3.5记录
安装参考:http://www.postgresql.org/download/linux/ubuntu/
y@y:~$ sudo apt-get install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 postgresql-server-dev-9.3 pgadmin3
* Starting PostgreSQL 9.3 database server [ OK ]
正在设置 postgresql-contrib-9.3 (9.3.5-0ubuntu0.14.04.1) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
表示安装成功。
配置:
1:使用psql客户端登录
y@y:~$ sudo -u postgres psql
psql (9.3.)
Type "help" for help.
2:修改PostgreSQL默认用户postgres的登录密码
PostgreSQL数据默认会创建一个postgres的数据库用户作为数据库的管理员,密码是随机的,所以这里要修改密码。
postgres=# alter user postgres with password 'postgres';
ALTER ROLE
3:退出PostgreSQL psql客户端
postgres-# \q
could not save history to file "/var/lib/postgresql/.psql_history": 没有那个文件或目录
(重新登录就可以了,由于第一次文件是不存在的)
4:修改linux系统的postgres用户的密码
y@y:~$ sudo passwd -d postgres
passwd:密码过期信息已更改。
y@y:~$ sudo -u postgres passwd
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
5:修改PostgresSQL数据库配置实现远程访问
y@y:~$ sudo vim /etc/postgresql/9.3/main/postgresql.conf
().监听任何地址访问,修改连接权限
#listen_addresses = ‘localhost’改为 listen_addresses = ‘*’
().启用密码验证
#password_encryption = on改为password_encryption = on
().可访问的用户ip段
y@y:/etc/postgresql/9.3/main$ sudo vim pg_hba.conf
并在文档末尾加上以下内容
# to allow your client visiting postgresql server
host all all 0.0.0.0 0.0.0.0 md5
():重启PostgreSQL数据库
y@y:~$ /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.3 database server * Error: You must run this program as the cluster owner (postgres) or root
[fail]
重启失败,提示需要root权限
y@y:~$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.3 database server [ OK ]
y@y:~$
6:管理PostgreSQL用户和数据库
()登录postgre SQL数据库
y@y:~$ sudo psql -U postgres -h 127.0.0.1
Password for user postgres:
()创建新用户test,但不给建数据库的权限
用户名要用双引号,以区分大小写,密码不用
postgres=# create user "test" password 'test' nocreatedb;
CREATE ROLE
()建立数据库,并指定所有者
postgres=# create database "testdb" with owner="test";
CREATE DATABASE ()在外部命令行的管理命令
postgres=# -u postgres createuser -D -P test1
-D该用户没有创建数据库的权利,-P提示输入密码,选择管理类型y/n
postgres-# -u postgres createdb -O test1 db1
-O设定所有者为test1
登录数据库
y@y:~$ psql -U test -d testdb -h 127.0.0.1 -p
Password for user test:
psql (9.3.)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: )
Type "help" for help. testdb=>
7:基本的数据库操作,就是使用一般的SQL语言
# 创建新表
CREATE TABLE user_tbl(name VARCHAR(20), signup_date DATE);
# 插入数据
INSERT INTO user_tbl(name, signup_date) VALUES('张三', '2013-12-22');
# 选择记录
SELECT * FROM user_tbl;
# 更新数据
UPDATE user_tbl set name = '李四' WHERE name = '张三';
# 删除记录
DELETE FROM user_tbl WHERE name = '李四' ;
# 添加栏位
ALTER TABLE user_tbl ADD email VARCHAR(40);
# 更新结构
ALTER TABLE user_tbl ALTER COLUMN signup_date SET NOT NULL;
# 更名栏位
ALTER TABLE user_tbl RENAME COLUMN signup_date TO signup;
# 删除栏位
ALTER TABLE user_tbl DROP COLUMN email;
# 表格更名
ALTER TABLE user_tbl RENAME TO backup_tbl;
# 删除表格
DROP TABLE IF EXISTS backup_tbl;
Ubuntu14.04安装PostpreSQL9.3.5记录的更多相关文章
- Ubuntu14.04安装配置web/ftp/tftp/dns服务器
目录: 1.安装ftp服务器vsftpd --基于tcp,需要帐号密码 2.安装tftp服务器tftpd-hpa,tftp-hpa --udp 3.web服务器--使用Apache2+Mysql+PH ...
- Ubuntu14.04安装intel集显驱动
Ubuntu14.04安装intel集显驱动 标签(空格分隔): ubuntu linux 驱动安装 1.查看本机显卡型号 使用lspci命令来获取PCI接口硬件信息 o@o-pc:~$ lspci ...
- Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题
1 设置中文显示环境 1. 打开System Settings 2. 打开Personal-> Language Support. 会弹出如下对话框,提示你“语言支持没安装完整”. 点击“Rem ...
- Ubuntu14.04安装配置ndnSIM
Ubuntu14.04安装配置ndnSIM 预环境 Ubuntu14.04官方系统 请先使用sudo apt-get update更新一下源列表 安装步骤 安装boost-lib sudo apt-g ...
- Ubuntu14.04 安装QQ国际版wine-qqintl
Ubuntu14.04安装qq国际版方式: 首先下载,链接为: https://pan.baidu.com/s/1boPitVD 密码:jp1j 也可去Ubuntu中文的Kylin(优麒麟)官网下载 ...
- 一.ubuntu14.04安装、亮度设置、显卡设置等一体化讲解
一.ubuntu14.04安装 安装步骤很简单的,相信你只要知道并且决定安装ubuntu,你就不会在安装上有问题,下载网址 http://www.ithome.com/html/soft/81539. ...
- Ubuntu14.04安装samba
Ubuntu14.04安装samba 按照惯例,首先介绍Samba.Samba是在Linux系统上实现的SMB(Server Messages Block,信息服务块)协议的一款免费软件.它实现在局域 ...
- Ubuntu14.04安装有道词典
Ubuntu14.04安装有道词典之前要更新系统: sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade 在有道官网下载 ...
- ubuntu14.04 安装redis 2.8.9
ubuntu14.04安装前准备工作,为了保证安装顺利,请先执行apt-get update 然后安装make 和gcc(已安装的可忽略) apt-get install make apt-get i ...
随机推荐
- 前端面试题之js篇
前端面试也可为是鱼龙混杂,各公司面试题的种类也大不相同,有的公司注重基础语法,面试题偏于ES,有的公司偏于页面逻辑,会考差一些js的应用,现将遇到过的题和典型的题整理一下. 1. 0.2-0.1 == ...
- 执行yiic webapp命令时报错:php.exe不是内部或外部命令,也不是可运行的程序
在执行 yiic webapp ../abc 命令时报错: “php.exe”不是内部或外部命令,也不是可运行的程序 或批处理文件. 这是因为yiic批处理程序找不到php.exe的执行路径引起的. ...
- hdu 1599 find the mincost route
http://acm.hdu.edu.cn/showproblem.php?pid=1599 floyd找最小环. #include <cstdio> #include <cstri ...
- poj2409 Let it Bead
Let it Bead Time Limit: 1000MS M ...
- LeetCode_Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequen ...
- Keil C51 详细设置
一.target名更改 打开Keil后,左侧Project Workspace中的target可改,方法:右击Target——Manage Compnents——双击待修改项即可,若要添加,使用对话框 ...
- UltraChart导出图片
? //一定要先绑定UltraChart,如果先绑定,然后有点击图片导出,没有用的 string fulPath="xxxx"; this.UltraChartTScore.Sav ...
- NSIS脚本根据操作系统版本动态决定默认安装目录
问题描述: 因为windows XP和windows 7的program files不同(有program files(x86)),所以需要动态根据系统的位数设置默认安装目录 References: ...
- leetcode_question_114 Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 ...
- haporxy 负载elasticsearch
<pre name="code" class="html">-bash-4.1# cat /etc/haproxy/haproxy.cfg glob ...