PostgreSQL 安装和配置

Posted in Tech on 2009/11/15 – 16:42
Post a comment

安装

$ emerge postgresql

配置

$ passwd postgres
$ emerge --config =postgresql-8.0.4
$ /etc/init.d/postgresql start
$ rc-update add postgresql default

使用

创建一个数据库:

$ createdb -U postgres -W test

删除一个数据库:

$ dropdb -U postgres -W test

创建一个超级用户:

createuser -a -d -P -E -U postgres -W testroot

其中-a 表示该用户可以添加其他用户. -d 表示该用户可以创建数据库. -P 让你为用户输入一个密码 -E 加密,出于安全目的.

创建一个标准用户:

createuser -A -D -P -E -U testroot -W testuser

-A,-D和-a,-d的作用相反,表示用户将被剥夺创建用户和数据库的能力

创建一个普通用户有权限的数据库MyDB:

$ createdb -O testuser -U testroot -W MyDB

登陆数据库:

psql -U testuser -W MyDB

更多

参考官方文档

如果你喜欢这篇文章,欢迎 订阅我的 RSS feed!


Tags: , |
This entry was written by youngking, filed under Tech and tagged , .
Bookmark the permalink or follow any comments here with the RSS feed for this post.
Both comments and trackbacks are currently closed.