每当创建新的Rails应用程序时,如何创建Postgres用户和数据库? [英] How can I create a Postgres user and database whenever I create a new rails app?

查看:119
本文介绍了每当创建新的Rails应用程序时,如何创建Postgres用户和数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了这个非常有用的教程:

I have followed this really helpful tutorial:

http://blog.willj.net/2011/05/31/setting-up-postgresql-for- ruby-on-rails-os-x /

我真的很想运行 rails new myapp code>并自动设置postgres数据库。我可以使用 Rails应用程序模板或类似的方法来做到这一点吗?

I would really like to run rails new myapp and have the postgres db set up automatically. Is there any way I can do that using a Rails application template or something similar?

推荐答案

在基于Unix的系统上:

On a unix based system:

sudo -u postgres createuser -d -R -P APPNAME
sudo -u postgres createdb -O APPNAME APPNAME

如果您不记得了,可以创建一个脚本并将其放在$ PATH中。

You can create a script and put it somewhere in your $PATH if you can't remember.

这篇关于每当创建新的Rails应用程序时,如何创建Postgres用户和数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆