个人工具
119.28.94.63
该IP地址的讨论
登录
查看“UbuntuHelp:PostgreSQL”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:PostgreSQL”的源代码
来自Ubuntu中文
←
UbuntuHelp:PostgreSQL
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/PostgreSQL}} {{Languages|UbuntuHelp:PostgreSQL}} === Introduction === [[UbuntuHelp:PostgreSQL|PostgreSQL]] is a powerful object-relational database management system, provided under a flexible BSD-style license.<sup>[1]</sup> [[UbuntuHelp:PostgreSQL|PostgreSQL]] contains many advanced features, is very fast and standards compliant. [[UbuntuHelp:PostgreSQL|PostgreSQL]] has bindings for many programming languages such as C, C++, [http://python.org/ Python], Java, PHP, Ruby... It can be used to power anything from simple web applications to massive databases with millions of records. === Installation === ==== Dapper ==== To install [[UbuntuHelp:PostgreSQL|PostgreSQL]] 8.1 you may use the command line and type : <pre><nowiki> sudo apt-get install postgresql-8.1 </nowiki></pre> pgAdmin III is a handy GUI for [[UbuntuHelp:PostgreSQL|PostgreSQL]], it is essential to beginners. To install type at the command line : <pre><nowiki> sudo apt-get install pgadmin3 </nowiki></pre> You may also use the Synaptic package manager from the System>Administration menu to install these packages. ==== Gutsy ==== To install '''Postgresql-8.2''' using your favorite package manager install the '''postgresql''' package. === Basic Server Setup === To start off, we need to change the [[UbuntuHelp:PostgreSQL|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: ==== Dapper ==== <pre><nowiki> sudo -u postgres psql template1 </nowiki></pre> ===== Gutsy ===== <pre><nowiki> sudo -u postgres psql postgres </nowiki></pre> Then, at the new prompt type these two commands, replacing <***password***> with the new password (keep this safe ;) ) : <pre><nowiki> ALTER USER postgres WITH ENCRYPTED PASSWORD ' <***password***> '; \q </nowiki></pre> ==== Create database ==== To create the first database, which we will call "mydb", simply type : <pre><nowiki> sudo -u postgres createdb mydb </nowiki></pre> === Using pgAdmin III GUI === To get an idea of what [[UbuntuHelp:PostgreSQL|PostgreSQL]] can do, you may start by firing up a graphical client. In a terminal type : <pre><nowiki> pgadmin3 </nowiki></pre> 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 Server === ==== Managing users and rights ==== [[UbuntuHelp:PostgreSQL|PostgreSQL]] has a not really easy way to manage users. To manage users, you first have to edit <code><nowiki>/etc/postgresql/8.1/main/pg_hba.conf</nowiki></code> and modify the default configuration which is very protective. For example, if you want <code><nowiki>postgres</nowiki></code> to manage its own users (not linked with system users), you will add the following line: <pre><nowiki> 8<------------------------------------------- # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD host all all 10.0.0.0 255.255.255.0 md5 8<------------------------------------------- </nowiki></pre> 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. To create a database with a user that have full rights on the database, use the following command: <pre><nowiki> sudo -u postgres createuser -D -A -P myuser sudo -u postgres createdb -O myuser mydb </nowiki></pre> The first command line creates the user the 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. === Further reading === If you are not familiar with [http://en.wikipedia.org/wiki/Sql SQL] you may want to look into this powerful language, although some simple uses of [[UbuntuHelp:PostgreSQL|PostgreSQL]] may not require this knowledge (such as a simple [http://www.djangoproject.com Django] project). The [http://www.postgresql.org/ [[UbuntuHelp:PostgreSQL|PostgreSQL]] website] contains a wealth of information on using this database. ---- <sup>[1]</sup> 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. <br> '''Note:''' this guide has been tested on Ubuntu 6.06 (Dapper) and Ubuntu 7.10 (Gutsy) ---- [[category:CategoryDocumentation]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:PostgreSQL
。