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

  • 十种最有效的QQ群推广方法(十种最有效的微信群管理方法)

    十种最有效的QQ群推广方法(十种最有效的微信群管理方法)

  • 苹果此时无法下载应用(苹果此时无法下载高德地图怎么回事)

    苹果此时无法下载应用(苹果此时无法下载高德地图怎么回事)

  • ipad键盘缩小了怎么复原(iPad键盘缩小了怎么变大)

    ipad键盘缩小了怎么复原(iPad键盘缩小了怎么变大)

  • 抖音里添加的表情在哪里找(抖音里添加的表情怎么添加到微信)

    抖音里添加的表情在哪里找(抖音里添加的表情怎么添加到微信)

  • 苹果手机用多久电池会从100变为99(苹果手机用多久电池会从100变为95)

    苹果手机用多久电池会从100变为99(苹果手机用多久电池会从100变为95)

  • 帧速率是不是越高越好(帧速率是不是越低越好)

    帧速率是不是越高越好(帧速率是不是越低越好)

  • 苹果4有录屏功能嘛(苹果4有录屏功能么)

    苹果4有录屏功能嘛(苹果4有录屏功能么)

  • 手机图片分辨率怎么看(手机图片分辨率太高怎么改低一点)

    手机图片分辨率怎么看(手机图片分辨率太高怎么改低一点)

  • 美版s20和国行区别(美版s20值得入手吗)

    美版s20和国行区别(美版s20值得入手吗)

  • 飞行模式短信延迟多久(飞行模式接收短信)

    飞行模式短信延迟多久(飞行模式接收短信)

  • qq里的群成员名片在哪(qq群名单)

    qq里的群成员名片在哪(qq群名单)

  • 对方qq卸载了有显示吗(对方qq卸载了有什么影响)

    对方qq卸载了有显示吗(对方qq卸载了有什么影响)

  • 手机淘宝怎么看天猫积分(手机淘宝怎么看自己的星级)

    手机淘宝怎么看天猫积分(手机淘宝怎么看自己的星级)

  • 微信辅助注册有风险吗(微信辅助注册有效期多久)

    微信辅助注册有风险吗(微信辅助注册有效期多久)

  • 华为防偷看手机屏设置(华为防偷看手机怎么关闭)

    华为防偷看手机屏设置(华为防偷看手机怎么关闭)

  • 手机里wadl可以删除吗(手机上可不可以)

    手机里wadl可以删除吗(手机上可不可以)

  • qq账号被冻结了几天才会恢复(qq账号被冻结了人脸识别不了怎么办)

    qq账号被冻结了几天才会恢复(qq账号被冻结了人脸识别不了怎么办)

  • 怎样把信息发到微信上(怎样把信息发到别人的邮箱里)

    怎样把信息发到微信上(怎样把信息发到别人的邮箱里)

  • 苹果xs max美版和国行区别(苹果xsmax美版和国行哪个好)

    苹果xs max美版和国行区别(苹果xsmax美版和国行哪个好)

  • 淘宝怎么上传宝贝(淘宝怎么上传宝贝主图视频)

    淘宝怎么上传宝贝(淘宝怎么上传宝贝主图视频)

  • 如何在BIOS中进行安全设置?联想笔记本电脑BIOS基本设置图文教程(bios咋进入)

    如何在BIOS中进行安全设置?联想笔记本电脑BIOS基本设置图文教程(bios咋进入)

  • 【时序列】时序列数据如何一步步分解成趋势(trend)季节性(seasonality)和误差(residual)- 详细理解python sm.tsa.seasonal_decompose(时序21-21-21-47)

    【时序列】时序列数据如何一步步分解成趋势(trend)季节性(seasonality)和误差(residual)- 详细理解python sm.tsa.seasonal_decompose(时序21-21-21-47)

  • 织梦dedecms 5.7自动给图片添加alt属性的教程(织梦cms官网)

    织梦dedecms 5.7自动给图片添加alt属性的教程(织梦cms官网)

  • 增值税销项进项什么意思
  • 福利费计提多了如何处理
  • 哪些进项税额不能加计抵减
  • 计提工资和实际发放工资必须一致吗
  • 出售的固定资产通过固定资产清理吗
  • 工会经费能零申报,可以计提工会经费吗
  • 发票税率开错了按什么申报
  • 离职人员个税申报如何处理
  • 费用类科目分类怎么避免出错
  • 年金的几种类型
  • 委托加工物资加工费怎么结转
  • 进口货物要交消费税吗
  • 印花税按什么税率
  • 金税盘维护费抵税会计分录
  • 增值税专用发票怎么开
  • 增值税确认平台一直显示该网站出现问题
  • 工行代收资金清算过渡户是什么?
  • 金融企业三大使命是什么
  • 文化事业建设费征收对象
  • 制造费用可以直接转入本年利润吗
  • 建筑工程预收款开票会计分录
  • 合并往来分录
  • 工资计提不发放工资个税
  • 企业向个人借款支付的利息
  • 小规模纳税人如何交增值税
  • 销售推广的常用形式
  • 去年的发票今年怎么做会计分录
  • 免税出口样品收多少税
  • googlechrome谷歌浏览器
  • 如何检查文档
  • iphone中的照片如何找回
  • 我国居民企业甲在境外进行了投资
  • Vue Grid Layout -️ 适用Vue.js的栅格布局系统(保姆级使用教程)
  • php静态缓存
  • 应税行为包括销售货物吗
  • vue foreach is not a function
  • php怎么设置图片的大小
  • opencv项目开发实战
  • 增值税专用发票进项
  • 外购货物用于在建工程分录
  • 四舍五入 vb
  • 事业单位财政拨款收入会计分录
  • 企业亏损了
  • 企业的其他应付款
  • 一般纳税人报税需要填哪些表
  • 资产负债表怎么看盈利或亏损
  • 无形资产摊销计算方法
  • 已经费用化的研发支出还可以资本化吗
  • 新会计准则贷款计提贷款减值准备的比例
  • 担保公司的担保费能退吗
  • 企业如何设置预缴税款
  • 银行打对公回单
  • 借别人的承兑后期还现钱可以吗?
  • 现金日记账和银行存款日记账必须逐日结出余额
  • 出纳建账的基本流程
  • MySql Error 1698(28000)问题的解决方法
  • win7怎么隐藏我的电脑
  • WINDOWS操作系统最新版本
  • macmini ubuntu
  • 在系统注册表中注册
  • ps1是什么文件
  • win8系统怎样关机
  • 怎么学linux
  • windows11内测版
  • 如何解决windows激活问题
  • [置顶] 此外,车牌号:458143(懂得都懂[吃瓜])
  • cocos2dx 4.0
  • python字符串常用方法
  • js css函数
  • hover在jquery中的用法
  • 原生js
  • 怎么做到开放
  • jquery改变img的src
  • jquery实现图片放大
  • 青岛税税通怎么切换企业
  • 小规模纳税人可以用专票抵扣税吗
  • 人文考试多少分合格
  • 出口报价必须含增值税吗
  • acfunp
  • 经营碎石的税点多少
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设