位置: IT常识 - 正文

install PostgreSQL Community Ubuntu Documentation

编辑:rootadmin
PostgreSQL - Community Ubuntu DocumentationPostgreSQL 目录 Introduction Client Installation Installati PostgreSQL

目录

Introduction Client Installation Installation Dapper Hardy Karmic, Lucid, Intrepid and Maverick Administration Basic Server Setup Dapper Karmic, Lucid, Intrepid and Maverick Create database Install Server Instrumentation for Postgresql 8.4 Alternative Server Setup Using pgAdmin III GUI Managing the Server Managing users and rights restarting the server Further reading External Links Turnkey LinuxIntroduction

PostgreSQL is a powerful object-relational database management system, provided under a flexible BSD-style license.[1] PostgreSQL contains many advanced features, is very fast and standards compliant.

PostgreSQL has bindings for many programming languages such as C, C++, Python, Java, PHP, Ruby... It can be used to power anything from simple web applications to massive databases with millions of records.

Client Installation

If you only wish to connect to a PostgreSQL server, do not install the whole PostgreSQL package, but install the PostgreSQL client instead. To do this, use the following command

sudo apt-get install postgresql-client

you then connect to the server with the following command

psql -h server.domain.org database user

After you inserted the password you access PostgreSQL with line commands. You may for instance insert the following

SELECT * FROM table WHERE 1;

You exit the connection with

\qInstallationDapper

To install PostgreSQL 8.1 you may use the command line and type:

sudo apt-get install postgresql-8.1Hardy

Install the latest Postgresql 8.3 from the command line with the following command:

sudo apt-get install postgresqlKarmic, Lucid, Intrepid and Maverick

To install Postgresql 8.4 you may use the command line and type:

sudo apt-get install postgresqlAdministration

pgAdmin III is a handy GUI for PostgreSQL, it is essential to beginners. To install it, type at the command line:

sudo apt-get install pgadmin3

You may also use the Synaptic package manager from the System>Administration menu to install these packages.

Basic Server Setup

To start off, we need to change the PostgreSQL postgres user password; we will not be able to access the server otherwise. As the “postgres” Linux user, we will execute the psql command.

In a terminal, type:

Dappersudo -u postgres psql template1Karmic, Lucid, Intrepid and Mavericksudo -u postgres psql postgres

Set a password for the "postgres" database role using the command:

\password postgres

and give your password when prompted. The password text will be hidden from the console for security purposes.

Type Control+D to exit the posgreSQL prompt.

Create database

To create the first database, which we will call "mydb", simply type:

sudo -u postgres createdb mydbInstall Server Instrumentation for Postgresql 8.4

To install Server Instrumentation for Postgresql 8.4 you may use the command line and type:

sudo apt-get install postgresql-contrib

Run the adminpack.sql script, simply type:

sudo -u postgres psql < /usr/share/postgresql/8.4/contrib/adminpack.sqlAlternative Server Setup

If you don't intend to connect to the database from other machines, this alternative setup may be simpler.

By default in Ubuntu, Postgresql is configured to use 'ident sameuser' authentication for any connections from the same machine. Check out the excellent Postgresql documentation for more information, but essentially this means that if your Ubuntu username is 'foo' and you add 'foo' as a Postgresql user then you can connect to the database without requiring a password.

Since the only user who can connect to a fresh install is the postgres user, here is how to create yourself a database account (which is in this case also a database superuser) with the same name as your login name and then create a password for the user:

sudo -u postgres createuser --superuser $USER sudo -u postgres psql postgres=# \password $USER

Client programs, by default, connect to the local host using your Ubuntu login name and expect to find a database with that name too. So to make things REALLY easy, use your new superuser privileges granted above to create a database with the same name as your login name:

createdb $USER

Connecting to your own database to try out some SQL should now be as easy as:

psql

Creating additional database is just as easy, so for example, after running this:

create database amarokdb;

You can go right ahead and tell Amarok to use postgresql to store its music catalog. The database name would be amarokdb, the username would be your own login name, and you don't even need a password thanks to 'ident sameuser' so you can leave that blank.

Using pgAdmin III GUI

To get an idea of what PostgreSQL can do, you may start by firing up a graphical client. In a terminal type :

pgadmin3

You will be presented with the pgAdmin III interface. Click on the "Add a connection to a server" button (top left). In the new dialog, enter the address 127.0.0.1, a description of the server, the default database ("mydb" in the example above), your username ("postgres") and your password.

With this GUI you may start creating and managing databases, query the database, execute SQl etc.

Managing the ServerManaging users and rights

To manage users, you first have to edit /etc/postgresql/8.1/main/pg_hba.conf and modify the default configuration which is very protective. For example, if you want postgres to manage its own users (not linked with system users), you will add the following line:

8<-------------------------------------------# TYPE DATABASE USER IP-ADDRESS IP-MASK METHODhost all all 10.0.0.0 255.255.255.0 md58<-------------------------------------------

Which means that on your local network (10.0.0.0/24 - replace with your own local network !), postgres users can connect through the network to the database providing a classical couple user / password.

Besides allowing a user to connect over the network to the to a database on the server, you must enable postgre to listen across different networks. To do that, open up /etc/postgresql/8.3/main/postgresql.conf in your favourite editor and alter the listen_addresses as below:

listen_addresses = '10.0.0.1,localhost'

where 10.0.0.1 describes the server's IP address on the local network. Note that this setting is commented out by default.

To create a database with a user that have full rights on the database, use the following command:

sudo -u postgres createuser -D -A -P myusersudo -u postgres createdb -O myuser mydb

The first command line creates the user with no database creation rights (-D) with no add user rights -A) and will prompt you for entering a password (-P). The second command line create the database 'mydb with 'myuser' as owner.

This little example will probably suit most of your needs. For more details, please refer to the corresponding man pages or the online documentation.

restarting the server

After configuring the networking / users you may need to restart the server, here is a suggested command to do so.

sudo /etc/init.d/postgresql-8.3 restartFurther reading

If you are not familiar with SQL you may want to look into this powerful language, although some simple uses of PostgreSQL may not require this knowledge (such as a simple Django project).

The PostgreSQL website contains a wealth of information on using this database.

推荐整理分享install PostgreSQL Community Ubuntu Documentation,希望有所帮助,仅作参考,欢迎阅读内容。

install PostgreSQL  Community Ubuntu Documentation

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

[1] You do not have to pay in order to use PostgreSQL for some applications, such as commercial closed source software, contrary to other well known open source databases.

Note: this guide has been tested on Ubuntu 6.06 (Dapper) and Ubuntu 7.10 (Gutsy)

External Links

The following are unverified suggestions made by users.

Turnkey Linux

An Ubuntu-based PostgreSQL appliance is one of the easiest ways to get up and running with PostgreSQL on Ubuntu. It's part of a family of pre-integrated TurnKey Linux Software Appliances based on Ubuntu 10.04.1 (Lucid LTS).

=== Xubuntu ====

The postgres command does not exist in the postgres package under recent postgres packages, fun.

# cat /var/lib/dpkg/info/postgresql.list /. /usr /usr/share /usr/share/doc /usr/share/doc/postgresql /usr/share/doc/postgresql/README /usr/share/doc/postgresql/copyright /usr/share/doc/postgresql/changelog.Debian.gz

本文链接地址:https://www.jiuchutong.com/zhishi/304541.html 转载请保留说明!

上一篇:爱上源码,重学Spring IoC深入

下一篇:ubuntu日志的设置(ubuntu系统日志配置文件)

  • 行程卡打不开什么原因(行程卡打不开了怎么回事)

    行程卡打不开什么原因(行程卡打不开了怎么回事)

  • 小米平板5怎么投屏(小米平板5怎么连接打印机)

    小米平板5怎么投屏(小米平板5怎么连接打印机)

  • 换了手机号怎么登录以前的QQ号(换了手机号怎么找回以前的抖音号)

    换了手机号怎么登录以前的QQ号(换了手机号怎么找回以前的抖音号)

  • 6s前置摄像头一片漆黑(6s前置摄像头模糊怎么回事)

    6s前置摄像头一片漆黑(6s前置摄像头模糊怎么回事)

  • soul功能升级中暂不支持修改(soul一直功能升级中)

    soul功能升级中暂不支持修改(soul一直功能升级中)

  • 抖音极速版刷视频为什么一直显示很遗憾(抖音极速版刷视频红包不转)

    抖音极速版刷视频为什么一直显示很遗憾(抖音极速版刷视频红包不转)

  • 微信上传头像模糊(微信头像上传图片为啥模糊)

    微信上传头像模糊(微信头像上传图片为啥模糊)

  • soul恋爱铃没有了(soul恋爱铃开了怎么不匹配)

    soul恋爱铃没有了(soul恋爱铃开了怎么不匹配)

  • 星号怎么打(星号怎么打在右上角)

    星号怎么打(星号怎么打在右上角)

  • 钉钉电脑版怎么退出全屏(钉钉电脑版怎么开启连麦)

    钉钉电脑版怎么退出全屏(钉钉电脑版怎么开启连麦)

  • 新手机不拆封能放多久(新手机不拆封能激活吗)

    新手机不拆封能放多久(新手机不拆封能激活吗)

  • vivox50微信视频带美颜吗(vivox50微信视频美颜在哪里)

    vivox50微信视频带美颜吗(vivox50微信视频美颜在哪里)

  • iphone se2是双卡吗(苹果是双卡)

    iphone se2是双卡吗(苹果是双卡)

  • 三星s8关机充电显示感叹号(三星s8关机充电时屏幕底端有黄色闪电)

    三星s8关机充电显示感叹号(三星s8关机充电时屏幕底端有黄色闪电)

  • jdn2-al00是什么型号(华为jdn2-al00是什么型号)

    jdn2-al00是什么型号(华为jdn2-al00是什么型号)

  • iphone5是什么时候上市的(iphone5是什么时候)

    iphone5是什么时候上市的(iphone5是什么时候)

  • 整理数据的方式有(整理数据的主要方法有哪些)

    整理数据的方式有(整理数据的主要方法有哪些)

  • 菜鸟裹裹默认什么快递(菜鸟裹裹默认寄件地址)

    菜鸟裹裹默认什么快递(菜鸟裹裹默认寄件地址)

  • word怎么设置文档纸张大小(word怎么设置文本格式)

    word怎么设置文档纸张大小(word怎么设置文本格式)

  • ps怎么改图片格式(ps怎么改图片格式为透明)

    ps怎么改图片格式(ps怎么改图片格式为透明)

  • 打开双4g有什么好处(手机开启双4g网络有什么好处)

    打开双4g有什么好处(手机开启双4g网络有什么好处)

  • wps表格文本转换数字(wps怎么文本转换表格)

    wps表格文本转换数字(wps怎么文本转换表格)

  • 红米应用怎么移到sd卡(红米应用怎么移动)

    红米应用怎么移到sd卡(红米应用怎么移动)

  • 腾讯大王卡激活时查不到订单(腾讯大王卡激活了怎么注销)

    腾讯大王卡激活时查不到订单(腾讯大王卡激活了怎么注销)

  • 小米8怎么设置来电秀(小米8怎么设置指纹解锁)

    小米8怎么设置来电秀(小米8怎么设置指纹解锁)

  • 抖音密码忘了手机号换了怎么办(抖音密码忘了手机号不用了怎么办)

    抖音密码忘了手机号换了怎么办(抖音密码忘了手机号不用了怎么办)

  • p30怎样关闭息屏指纹显示(华为p30取消灭屏显示时间怎么设置)

    p30怎样关闭息屏指纹显示(华为p30取消灭屏显示时间怎么设置)

  • 手机信号边上出现hd是什么意思(手机信号边上出现米数什么情况)

    手机信号边上出现hd是什么意思(手机信号边上出现米数什么情况)

  • 三星note9屏幕多少hz(三星note9屏幕参数)

    三星note9屏幕多少hz(三星note9屏幕参数)

  • 复制过的东西在哪里找(复制过的东西在哪里打开)

    复制过的东西在哪里找(复制过的东西在哪里打开)

  • 前端开发神器VS Code安装教程(前端开发软件哪个最好)

    前端开发神器VS Code安装教程(前端开发软件哪个最好)

  • 资管产品增值税由谁承担
  • 税负怎么计算
  • 支付给个人的佣金费用需要发票吗
  • 物业缴纳发票可以抵税吗
  • 附加税已扣款还要季度申报吗
  • 支付临时工劳务费700元需要开发票吗
  • 房产经纪公司成本费用
  • 外地发票是什么意思
  • 增值税发票验证
  • 注销地税需要缴纳什么税费
  • 车贷抵押金计入会计科目?
  • 预付材料款的会计分录怎么写
  • 分项结转分步法例题及分录
  • 营改增后机械设备租赁需缴纳什么税?
  • 商品流水账怎么做
  • 一般纳税人错开免税发票如何申报
  • 出口退税的账务关键是什么
  • win10怎么接收手机热点
  • 电脑输入法切换键怎么设置
  • win10更新补丁卸载不了
  • 以租代购算固定资产吗
  • u启动怎么装机
  • 圣米歇尔山 (© Leroy Francis/Getty Images)
  • windows update更新错误
  • 股权处置的形式
  • win11专业版网卡安不了
  • 企业所得税汇算交税分录
  • edge浏览器about:flags
  • unigui 小程序
  • 应付职工薪酬是负数是什么意思
  • phalcon model在插入或更新时会自动验证非空字段的解决办法
  • 【AIGC】6、Segment Anything | Meta 推出超强悍可分割一切的模型 SAM
  • react moment
  • 文心一格百度
  • redux-tookit
  • 客户不要的专票我们可以不作废吗
  • 帝国cms怎么样
  • 公司租个人房屋交什么税
  • mongodb建立索引的命令
  • 扣缴义务人如何登录电子税务局
  • 实收资本报表怎么填
  • 增值税红字发票怎么填开
  • 研发人员的差旅费计入管理费用吗
  • 在软件中的操作有哪些
  • 利息收入应该怎么记账
  • 购进固定资产的账务处理
  • 无法收回的应收账款可以税前扣除吗
  • 贷款的融资担保费
  • 计提待摊费用分录
  • 账户信息变更说明
  • 高速etc里面的钱怎么取?
  • 百旺金赋服务费可以不交吗
  • 填制记账凭证有哪些
  • 总账的建立
  • 工业企业生产什么
  • 搜索框打开
  • linux/unix
  • 如何设置windows启动密码
  • Linux怎么删除文件第一行
  • 如何解决笔记本电脑温度过高 蓝屏
  • ubuntu误删除内核
  • 3.0vray安装教程
  • win8待机后无法唤醒
  • 歌词特效是怎么弄的
  • 华为nova7耳机怎么戴
  • vb win7
  • 安卓的系统设置在哪
  • android应用程序开发的流程
  • cocos2dx运行原理
  • js控制鼠标位置
  • 欢迎使用城市供水信息服务平台
  • nodejs 代理请求
  • python 批量查询
  • javascript原型链详解
  • JAVAscript字符串类型单引号和双引号意一样吗
  • javascript零基础
  • 税率是从什么时候有17%改为13%的呢
  • 联华超市华联超市哪个厉害
  • 小规模纳税人的增值税怎么计算
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设