rails postgresql数据库连接

rails postgresql数据库连接,postgresql,sudo,rails-postgresql,Postgresql,Sudo,Rails Postgresql,我正在尝试为我的rails应用程序使用postgresql数据库 我遵循了此链接中提供的教程: http://blog.crowdint.com/2010/10/27/working-with-postgresql-and-rails3.html 我使用以下命令成功安装了postgresql: sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev libpgsql-ruby libgda-4

我正在尝试为我的rails应用程序使用postgresql数据库

我遵循了此链接中提供的教程:

http://blog.crowdint.com/2010/10/27/working-with-postgresql-and-rails3.html
我使用以下命令成功安装了postgresql:

sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev libpgsql-ruby libgda-4.0-postgres libpq-dev
sudo -u postgres psql template1
当我到达创建用户的行时,我输入了以下命令:

sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev libpgsql-ruby libgda-4.0-postgres libpq-dev
sudo -u postgres psql template1
但在我为root输入密码后,它给了我一个错误

env: -u: No such file or directory

知道为什么会出现错误吗?

听起来您的用户可能会把环境/路径弄得一团糟。我不确定你是在mac还是linux/unix上运行,但我在Ubuntu论坛上找到了一篇可能与你的问题有关的帖子:

我不确定别名是否为“ing sudo”(第2页回复)

这是最好的永久解决方案,但它为他解决了问题。我的sudo上没有这样的别名,所以我认为通过profile/export命令有一个更好的解决方案,并会邀请某人提供更好的答案


希望这有帮助

这不是对您的直接问题的回答,但如果您还没有使用它,我强烈建议您下载并使用PGadmin,这是postgres gui的主要管理工具,将对您有很大帮助。