Rails postgresql 数据库连接

发布于 2024-11-30 10:20:02 字数 556 浏览 4 评论 0原文

我正在尝试为我的 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

但是在我输入 root 的密码后,它给了我一个错误,说

env: -u: No such file or directory

知道为什么错误弹出?

I am trying to use a postgresql database for my rails app.

I followed the tutorials provided in this link:

http://blog.crowdint.com/2010/10/27/working-with-postgresql-and-rails3.html

I successfully installed postgresql with this command:

sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev libpgsql-ruby libgda-4.0-postgres libpq-dev

When I reached the line to create a user I entered this command:

sudo -u postgres psql template1

But after I entered a password for root it gave me an error saying

env: -u: No such file or directory

Any idea why the error popped up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼前雾蒙蒙 2024-12-07 10:20:02

听起来环境/路径可能对您的用户来说很混乱。我不确定您是否在 mac 或 linux/unix 上运行,但我在 Ubuntu 论坛上找到了一篇可能与您的问题相关的帖子:

sudo 坏了

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

alias sudo='sudo env PATH=$path'

是最好的永久解决方案,但它为他修复了它。我的 sudo 上没有这样的别名,所以我认为通过配置文件/导出命令有更好的解决方案,并且会邀请某人提供更好的答案。

希望这有帮助

It sounds like the environment/path may be messed up for your user. I'm not sure if you're running on mac or linux/unix but I found a post from the Ubuntu forums that may be related to your problem:

sudo is broken

I'm not sure if alias'ing sudo (page 2 reply)

alias sudo='sudo env PATH=$path'

is the best permanent solution but it fixes it for him. I have no such alias on my sudo so I'm thinking there's a better solution via profile / export command and would invite someone to provide a better answer.

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文