位置: 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系统日志配置文件)

  • oppoa36手机是快充吗(oppo手机有没有快充功能)

    oppoa36手机是快充吗(oppo手机有没有快充功能)

  • qq空间怎么发动态呢(qq空间怎么发动态)

    qq空间怎么发动态呢(qq空间怎么发动态)

  • 多多视频点赞的视频在哪(多多视频点赞的视频怎么删除)

    多多视频点赞的视频在哪(多多视频点赞的视频怎么删除)

  • 哔哩哔哩怎么换绑手机号(哔哩哔哩怎么换实名认证)

    哔哩哔哩怎么换绑手机号(哔哩哔哩怎么换实名认证)

  • 微信注销授权解除不了(微信注销授权解除要多久)

    微信注销授权解除不了(微信注销授权解除要多久)

  • 电脑管家跑分多少算好

    电脑管家跑分多少算好

  • 苹果8要不要升级ios13

    苹果8要不要升级ios13

  • 抖音多久能改一次名字(抖音多久能改一次头像)

    抖音多久能改一次名字(抖音多久能改一次头像)

  • mi9是什么手机(下一页p30)

    mi9是什么手机(下一页p30)

  • 苹果手机和手表可以最远保持多远距离(苹果手机和手表距离多远断开)

    苹果手机和手表可以最远保持多远距离(苹果手机和手表距离多远断开)

  • vivo手机关机键失灵了怎么办(vivo手机关机键坏了怎么修)

    vivo手机关机键失灵了怎么办(vivo手机关机键坏了怎么修)

  • vivo手机怎么传数据到新手机(vivo手机怎么传照片到电脑)

    vivo手机怎么传数据到新手机(vivo手机怎么传照片到电脑)

  • 快手运营人员是干嘛的(快手运营岗)

    快手运营人员是干嘛的(快手运营岗)

  • qq注销了对方还有聊天记录吗(qq注销了对方还能查到我吗)

    qq注销了对方还有聊天记录吗(qq注销了对方还能查到我吗)

  • 支付宝加好友需要对方同意吗(支付宝加好友需要发送验证消息吗)

    支付宝加好友需要对方同意吗(支付宝加好友需要发送验证消息吗)

  • 声卡插在主板的什么位置(声卡插在主板的哪个位置)

    声卡插在主板的什么位置(声卡插在主板的哪个位置)

  • 小爱音箱可以连接手机热点么(小爱音箱可以连接酷狗音乐吗)

    小爱音箱可以连接手机热点么(小爱音箱可以连接酷狗音乐吗)

  • 铅盒能屏蔽手机信号吗(铅盒屏蔽手机信号)

    铅盒能屏蔽手机信号吗(铅盒屏蔽手机信号)

  • 苹果7手机有几种型号内存(苹果7手机有几个喇叭)

    苹果7手机有几种型号内存(苹果7手机有几个喇叭)

  • Realme是什么牌子(realme是什么牌子的手机)

    Realme是什么牌子(realme是什么牌子的手机)

  • 爱奇艺vf是vip还要钱吗(爱奇艺vip是什么意思)

    爱奇艺vf是vip还要钱吗(爱奇艺vip是什么意思)

  • 小米手环监测睡眠准吗(小米手环监测睡眠的原理)

    小米手环监测睡眠准吗(小米手环监测睡眠的原理)

  • qq加别人好友对方没收到验证(QQ加别人好友对方知道你的手机号码)

    qq加别人好友对方没收到验证(QQ加别人好友对方知道你的手机号码)

  • 比心怎么认证(比心怎么认证大神2022)

    比心怎么认证(比心怎么认证大神2022)

  • 爆米花视频怎么搜索自己要看的(爆米花视频怎么没有搜索功能)

    爆米花视频怎么搜索自己要看的(爆米花视频怎么没有搜索功能)

  • 探探为什么收不到信息(探探为什么收不了验证码)

    探探为什么收不到信息(探探为什么收不了验证码)

  • Oppo reno的CPU型号是那种(opporeno系列的处理器是多少啊)

    Oppo reno的CPU型号是那种(opporeno系列的处理器是多少啊)

  • 抖音怎么删除一小段(抖音怎么删除一段)

    抖音怎么删除一小段(抖音怎么删除一段)

  • qq群发祝福在哪里打开(qq群发祝福在哪为什么我找不到)

    qq群发祝福在哪里打开(qq群发祝福在哪为什么我找不到)

  • OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading “C:\ProgramData\Anaconda3\lib\site-packages\to

    OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading “C:\ProgramData\Anaconda3\lib\site-packages\to

  • 公司租的住宅和商品房
  • 城镇土地使用税的计税依据
  • 进口关税的计算方式
  • 居民个人所得计算怎么做
  • 房地产企业成本包括哪些
  • 以前多摊销
  • 滴滴上开的发票是增值税发票还是普通发票
  • 税控设备抵减增值税政策
  • 个体户3万免税免的是哪些税
  • 租借车辆发生事故后的保险理赔问题
  • 房地产企业广告费扣除基数
  • 房产企业赠送无形资产
  • 房地产怎么计算需要交多少税
  • 汽车区域差价
  • 残料的会计分录
  • 出售固定资产要交哪些税
  • 外汇汇率在其中扮演什么角色?
  • 税法三流合一是哪一项法律依据
  • 出售子公司全部股权的股权账务处理
  • 如何不同版本复制粘贴
  • 计提工资和发放工资区别
  • 收到政府部门的奖励金怎么入账
  • Win11怎么隐藏底部
  • qq登录界面的设计与实现
  • win11任务管理器怎样调出
  • rtvscn95.exe - rtvscn95是什么进程 有什么用
  • PHP:curl_copy_handle()的用法_cURL函数
  • PHP:pg_field_prtlen()的用法_PostgreSQL函数
  • powergenie是什么程序
  • 无法连接到你的相机,请重启手机
  • 代理业务怎么记账
  • 以分期收款方式销售货物的按照什么日期确认收入的实现
  • 应税消费品投资的筹划方法
  • php实现图片上传显示
  • php的implode
  • 生产企业 制造商
  • 收到现金货款存入银行会计分录
  • php十进制转二进制算法
  • 诉讼费属于什么费用
  • 购进食用油的会计分录
  • 用php写的一个冒号的句子
  • k8s控制器模式
  • js如何转换为数值型
  • 编程中char什么意思
  • setenforce 0命令
  • ecshop功能
  • 一般纳税人暂估入账的会计分录
  • 土地出让金抵扣进项税
  • 罚款可以直接在12123
  • 差旅费适用税率
  • 股东权益合计是净资产吗
  • 销售商品该如何改进服务
  • 哪些发票可以报销哪些不可以
  • 固定资产补缴增值税怎么做帐务处理
  • 公司购入的房子卖了,如何交增值税
  • 专打发票的打印机
  • 付款与开票单位不一致怎样做账
  • 资产减值损失审计程序是什么
  • 公司营运成本
  • w10预览版新功能
  • windows预览版和正式版区别
  • msg0是什么文件
  • 应该怎么修复
  • win10查看电脑配置显卡
  • unity输入中文
  • nodejs读取json文件,并返回列表
  • perl里怎么对数组实现一次遍历
  • bootstrap 下拉按钮
  • android studio入门项目
  • 关于批处理的说法错误的是
  • js文件设置编码
  • jQueryUI Datepicker组件设置日期高亮
  • jquery 弹出页面
  • 河南省发票查询真伪查询系统
  • 农产品销售个人所得税
  • 天府新区劳动局投诉电话
  • 中国烟草一年税收占全国总收入
  • 个体户 零申报
  • 山东发票认证勾选平台网址
  • 怎样通过发票号码查询电子发票
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设