Posts tagged with: database

PostgreSQL 安装和配置

2009/11/15 – 16:42

安装

$ 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 [...]

By youngking | Posted in Tech | Also tagged | 评论关闭