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

  • oppo手机怎么发短信(oppo手机怎么发朋友圈不带图片)

    oppo手机怎么发短信(oppo手机怎么发朋友圈不带图片)

  • 小米手环6怎么换自定义壁纸(小米手环6怎么调时间)

    小米手环6怎么换自定义壁纸(小米手环6怎么调时间)

  • 微信视频如何恢复(微信视频如何恢复原视频)

    微信视频如何恢复(微信视频如何恢复原视频)

  • 显卡没有供电接口怎么办(显卡没有供电接口,可不可以用带显卡电源接口的电源)

    显卡没有供电接口怎么办(显卡没有供电接口,可不可以用带显卡电源接口的电源)

  • a1779苹果7什么版本(苹果七a1778)

    a1779苹果7什么版本(苹果七a1778)

  • siri建议有什么用途(siri建议的app是经常用还是什么)

    siri建议有什么用途(siri建议的app是经常用还是什么)

  • 微信提醒怎么取消(微信提醒怎么取消安卓)

    微信提醒怎么取消(微信提醒怎么取消安卓)

  • 微信更换实名认证里面的钱会不会没(微信更换实名认证的全过程)

    微信更换实名认证里面的钱会不会没(微信更换实名认证的全过程)

  • qq已删除照片在哪里(qq里删除的照片)

    qq已删除照片在哪里(qq里删除的照片)

  • iphonex能无线充电吗(苹果x能无线充电)

    iphonex能无线充电吗(苹果x能无线充电)

  • qq删除的照片怎么找回来(qq删除的照片怎么恢复)

    qq删除的照片怎么找回来(qq删除的照片怎么恢复)

  • word怎么输入下标(word怎么输入下划线)

    word怎么输入下标(word怎么输入下划线)

  • 手机没有电池直接充电能开机吗(手机没有电池直接插充电器怎么开不起机)

    手机没有电池直接充电能开机吗(手机没有电池直接插充电器怎么开不起机)

  • 电脑qq上怎么打印照片(电脑QQ上怎么打开腾讯会议)

    电脑qq上怎么打印照片(电脑QQ上怎么打开腾讯会议)

  • 苹果如何设置定时电话(苹果如何设置定时开关机)

    苹果如何设置定时电话(苹果如何设置定时开关机)

  • 抖音管理员怎么踢人(抖音管理员怎么发飘屏文字)

    抖音管理员怎么踢人(抖音管理员怎么发飘屏文字)

  • vivoz5x反向充电怎么用(vivoz5x反向充电需要线吗)

    vivoz5x反向充电怎么用(vivoz5x反向充电需要线吗)

  • 苹果xs没有指纹解锁了吗(苹果13有没有指纹)

    苹果xs没有指纹解锁了吗(苹果13有没有指纹)

  • 怎么把快手喜欢的清零(怎么把快手喜欢打开)

    怎么把快手喜欢的清零(怎么把快手喜欢打开)

  • 手机有信号但是打不出去电话(手机有信号但是没有4G怎么回事)

    手机有信号但是打不出去电话(手机有信号但是没有4G怎么回事)

  • 如何让对方看不到自己的手机号(如何让对方看不见正在输入)

    如何让对方看不到自己的手机号(如何让对方看不见正在输入)

  • 【HTML+CSS】实现网页的导航栏和下拉菜单(html cssjs)

    【HTML+CSS】实现网页的导航栏和下拉菜单(html cssjs)

  • 链表(链表的优缺点有哪些)

    链表(链表的优缺点有哪些)

  • 城建税和教育费附加
  • 增值税开票软件口令锁定怎么办
  • 补缴以前年度增值税和罚款、滞纳金的所得税处理
  • 税盾是怎么产生的
  • 办公费税前扣除标准2023
  • 固定资产账务处理实操
  • 金蝶k3如何设置凭证保存自动新增
  • 建筑公司多个项目,增值税收入确认
  • 公司网站建设费做账是流量应计入
  • 劳务公司劳务协议范本
  • 报税盘金税盘领的发票能通用吗
  • 火车票抵扣进项税怎么计算
  • 职工取暖费可以一次性发放吗
  • 开票金额大于收款金额如何处理
  • 工地工资是人走账清吗
  • 事业单位开办费账务处理
  • 一般纳税人在外地预缴税款
  • 支付土地流转费
  • 销售使用固定资产账务怎么处理
  • 股东转让股权印花税怎么交税
  • 不交社保的单位违法吗?
  • 处置交易性金融资产发生的交易费用
  • 境外单位向境内单位提供咨询
  • 代缴代扣增值税
  • 我的初级备考经验------极限挑战,超越自我
  • 对公账户转账有延迟吗
  • 食堂伙食费需要开票吗
  • 房地产企业预缴增值税如何申报
  • 出口退税附加税计税依据
  • 建筑工程劳务费占比例
  • 应用程序出现异常怎么办
  • 怎么用老毛桃u盘装win7系统 老毛桃u盘装win7系统教程图解
  • 网络环境中存在不同网段的nvr
  • php 链式调用
  • 扩展组件可以删除吗
  • 手续费及佣金扣除标准
  • 私募股权基金备案流程
  • 企业支付的贷款计入gdp
  • phpstrcmp函数
  • 偷税行为五年后被发现要接受行政处罚吗?
  • 投资性房地产如何计提折旧
  • 利润总额为负还交所得税吗
  • 浅谈php的排列组合
  • php主要用于
  • 不能抵扣的福利发票要勾选吗为什么
  • 无法报销的原因
  • 代垫运费增值税计入销项税额吗
  • 帝国cms吧
  • 让渡资产属于什么
  • 增值税发票跨月红冲操作流程
  • 企业所得税季度申报数据怎么来
  • 现金返利的会计分录
  • 港币转人民币怎么算
  • 在建工程物资属于存货吗
  • 暂估入账会计科目
  • 结转未交增值税为什么是零
  • 去税务局核定税种多久生效
  • 融资租入固定资产计提折旧吗
  • LNMP下使用命令行导出导入MySQL数据库的方法
  • 电脑bios怎么关
  • winxp启动
  • ubuntu怎么禁用nouveau
  • win8无线网络连接不上
  • mac重装macos
  • WIN7系统如何设置表格默认保存位置
  • jsp环境变量配置的步骤
  • xp密码忘记了怎么办大神
  • window10耳机有电流
  • ERROR 1045: Access denied for user: root@localhost (Using password: NO)
  • 斗西游破解版
  • Unity3d_NGUI和UGUI的学习
  • javascript教程
  • 我的第一个师父读后感
  • python的删除
  • jquery遍历dom
  • python socket sendto
  • js中的require函数
  • python移动目标跟踪
  • 国家税务总局现任局长
  • 中华人民共和国道路交通安全法
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设