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

  • 微信扫码付款能查到付款人信息吗(微信扫码付款能查到对方微信号吗)

    微信扫码付款能查到付款人信息吗(微信扫码付款能查到对方微信号吗)

  • win10教育版和专业版的区别(win10教育版和专业版的区别打游戏)

    win10教育版和专业版的区别(win10教育版和专业版的区别打游戏)

  • 苹果手机时间慢一分钟怎么解决(苹果手机时间慢一分钟怎么调)

    苹果手机时间慢一分钟怎么解决(苹果手机时间慢一分钟怎么调)

  • 蓝牙耳机发微信语音不清楚(蓝牙耳机发微信语音延迟怎么解决)

    蓝牙耳机发微信语音不清楚(蓝牙耳机发微信语音延迟怎么解决)

  • 红米手机经常自动静音(红米手机经常自动重启)

    红米手机经常自动静音(红米手机经常自动重启)

  • 魅族17跟17pro有什么区别(魅族17和17pro评测)

    魅族17跟17pro有什么区别(魅族17和17pro评测)

  • 怎么去除word里面的小回车箭头(怎么去除word里面的链接)

    怎么去除word里面的小回车箭头(怎么去除word里面的链接)

  • 去哪儿vip抢票一定能抢到吗(去哪儿vip抢票一天几次)

    去哪儿vip抢票一定能抢到吗(去哪儿vip抢票一天几次)

  • 一碰传支持小米手机吗(一碰传支持机型)

    一碰传支持小米手机吗(一碰传支持机型)

  • 多媒体计算机软件系统由什么组成(多媒体计算机软件系统不包括)

    多媒体计算机软件系统由什么组成(多媒体计算机软件系统不包括)

  • ipad软件都是收费的吗(苹果平板里面的app都收费吗)

    ipad软件都是收费的吗(苹果平板里面的app都收费吗)

  • 怎么知道对方在视频(怎么知道对方在国外还是国内)

    怎么知道对方在视频(怎么知道对方在国外还是国内)

  • 乐视手机怎么导出联系人(乐视手机怎么导入联系人)

    乐视手机怎么导出联系人(乐视手机怎么导入联系人)

  • 苹果x跟苹果11对比(苹果x跟苹果11对比图片)

    苹果x跟苹果11对比(苹果x跟苹果11对比图片)

  • 龙江人社网络异常什么情况(龙江人社网络异地登录)

    龙江人社网络异常什么情况(龙江人社网络异地登录)

  • wds桥接和中继的区别(wds桥接和中继哪个网速快)

    wds桥接和中继的区别(wds桥接和中继哪个网速快)

  • 余利宝收益怎么算(余利宝收益怎么是负的)

    余利宝收益怎么算(余利宝收益怎么是负的)

  • 8p屏幕发黄如何调节

    8p屏幕发黄如何调节

  • 电脑guest关闭方法(关闭guest账户)

    电脑guest关闭方法(关闭guest账户)

  • 曼哈顿河滨公园中的圣女贞德纪念碑 (© Chase Guttman/Alamy)(曼哈顿公园大道432号)

    曼哈顿河滨公园中的圣女贞德纪念碑 (© Chase Guttman/Alamy)(曼哈顿公园大道432号)

  • 【运筹优化】带时间窗约束的车辆路径规划问题(VRPTW)详解 + Python 调用 Gurobi 建模求解(运筹最优化方法有哪些)

    【运筹优化】带时间窗约束的车辆路径规划问题(VRPTW)详解 + Python 调用 Gurobi 建模求解(运筹最优化方法有哪些)

  • 共享税种
  • 旅游业成本具体有哪些
  • 减免税款最终转到哪个科目?
  • 税收要素的灵魂
  • 车辆购置税的税率是多少
  • 顺流交易为什么调整被投资方
  • 企业为员工承担的个税可以税前扣除吗
  • 工资结算单属于通用凭证吗
  • 会计核算制度的案例
  • 汇票贴现的账务处理
  • 职工福利费税前扣除限额
  • 合并报表编织原则
  • 安装工程劳务合同
  • 企业装载机管理制度
  • 主营业务税金及附加包括印花税吗
  • 纳税调整增加额和纳税调整减少额
  • 没有缴纳契税
  • 购进旅客运输服务抵扣会计分录
  • 个人劳务费可以不开发票吗
  • 境外施工
  • 融资融券主要是哪些对象
  • 贷款公司利息收据怎么写
  • 利息收入营业收入
  • 上月没交社保本人能交吗
  • 收到进项发票抵扣联怎么做分录
  • 年报企业控股情况怎么填
  • 附加税要先计提再支付吗
  • 个税系统人员信息一直在验证中
  • 手工明细分类账本怎么记
  • desktop病毒
  • 基金的管理费用包括什么
  • 收到进项税发票如何入账
  • 一般纳税人出售旧设备的税率
  • 电脑语言栏不见了,打不出汉字
  • 织梦地图插件
  • 出口企业如何确认增值税收入
  • 非货币性资产交换以公允价值为基础进行计量
  • 事业单位委托业务费的现金流量
  • 深度计算公式
  • php编写登陆界面
  • 网上学电脑的软件
  • 往账来账是什么意思
  • 公司为员工代扣代缴
  • 应付票据是商业承兑汇票吗
  • 预缴的企业所得税能抵扣企业所得额嘛
  • 租赁公司一般都有什么税
  • mongodb基础知识
  • 小微企业可以不交税吗
  • 酒店行业销售费用占比
  • 特惠贷贴息金额怎么算的
  • 原材料盘亏属于自然损耗
  • 固定补贴是否属于社保
  • 开票信息修改
  • sql表添加字段
  • 个人出租房屋需要缴纳个税吗
  • 暂估入库结转成本后如何冲红
  • 公司注销实收资本账务处理
  • 低值易耗品怎么摊
  • 小规模纳税人增值税专用发票税率
  • 企业项目的特点
  • 福利费的范畴
  • 旅游饮食服务企业财务会计制度
  • 分页查询效率
  • 在64位的Ubuntu系统上安装32位的WPS的方法
  • linux 添加ipv6路由
  • zhp.exe是什么进程
  • linux修改软件源
  • linux安装flash插件
  • linux小技巧
  • node.js批量添加数据
  • system命令行
  • 如何解决android兼容问题
  • javascript运用
  • unity游戏开发简历
  • jquery日期控件 datepicker
  • android中的webview
  • 江西省发票查询系统
  • 广东每年交多少税给国家
  • 同比减少怎么计算出来
  • 惠济区第五中学怎么样
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设