Gaz*_*ler 14

在基于unix的系统上:

sudo -u postgres createuser -d -R -P APPNAME
sudo -u postgres createdb -O APPNAME APPNAME
Run Code Online (Sandbox Code Playgroud)

如果您不记得,可以创建一个脚本并将其放在$ PATH中的某个位置.

  • 只是为了完成,`createuser -d -R -P将创建一个用户,可以创建一个db(-d),不能创建角色(-R),并提示输入密码(-P)`http:// www.postgresql.org/docs/9.1/static/app-createuser.html`createb -O将创建一个具有指定所有者的数据库(-O)`http://www.postgresql.org/docs/9.1/static/ APP-createdb.html (5认同)

gab*_*lal 8

实际上,每次创建新的rails应用程序时都不需要创建新用户.

您所要做的就是创建新的应用程序并更改username您的应用程序database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: newapp_development
  pool: 5
  username: #your username
  password:
...
Run Code Online (Sandbox Code Playgroud)

而不仅仅是:

rake db:create:all
Run Code Online (Sandbox Code Playgroud)