在 Snow Leopard 上设置 Rails 3.1 和 Postgresql
我花了无数个小时尝试在我的 Intel Mac 上设置 PostgreSql。
我能够安装 Rails,但除了 PostgreSql 之外的所有内容都不会安装在我的 Mac 上。
任何人都有任何解决方案或任何我可以遵循的教程来安装它?
PS 我刚刚开始使用 Mac 作为我的开发机器。在此之前我一直使用Windows!
I have spent countless number of hours trying to setup PostgreSql on my Intel Mac.
I am able to install Rails and all but PostgreSql would not get installed on my Mac.
Anybody has any solution or any tutorial which I can follow to install it ??
P.S. I just started using Mac as my development machine. I have been using Windows before that !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好吧,我必须以新的心态做更多的研究,现在我能够自己解决问题了。这是解决方案:
使用此命令安装 Homebrew:
安装后在终端中写入以下内容:
如果这是您第一次安装(我就是这种情况),则在执行上述步骤后在终端中键入以下内容:
要启动 postgresql,请键入以下内容终端:
在上述步骤之后键入:
如果上述命令在终端中的结果如下所示,则表示 postgresql 已正确安装:
创建用户和数据库:
要登录 postgresql,请使用此命令:
如果你是将它与 Rails 一起使用,您可以像这样安装 gem:
如果您想停止 PostgreSQL 服务,请使用此命令:
希望这将帮助其他人节省像我一样通过不同资源来获得解决方案的时间:)
Ok I had to do a little more research with a fresh mind and I am now able to solve the problem myself. Here is the solution :
Install Homebrew using this command :
Once installed write this in your terminal :
If this is your first install ( which was the case with me ) than type this in terminal after the above step:
To start the postgresql type this in terminal:
After the above step type this :
If the result of the above command in terminal looks like this than that means the postgresql is installed correctly :
Create a user and database:
To login to postgresql use this command:
If you are using it with rails you can install the gem like this :
If you would like to stop the PostgreSQL service use this command :
Hope this will help others in saving the time of going through different resources to come with the solution like I did :)
尝试使用灰姑娘。这将在
~/Developer
中为您提供整个堆栈(包括 MongoDB、Redis 和一大堆其他内容)。您最好使用所有开发工具的自定义构建,这样您就不必担心系统附带的任何版本以及升级可能会对您的操作系统造成什么影响。参考资料:
Try using Cinderella. That will give you the whole stack (including MongoDB, Redis, and a whole bunch of other stuff) in one nice neat bundle in
~/Developer
. You're better off using custom builds of all your development tools so that you don't have to worry about what version of anything comes with the system and what an upgrade might to do your OS.References:
需要添加到您的说明中的其他一些注释:
Russ Brooks 安装博客,它验证了您上面的大部分内容。
pgadmin.org 提供了一组管理工具,可让您通过简单的 GUI 浏览数据库Mac
如果您使用管理工具,您应该使用以下命令安装工具包:
其中确切的命令显然取决于您正在使用的 postgresql 版本。
如果您将 postgres 与 Rails 和捆绑器一起使用,请确保“pg”gem 位于您的 gem 文件中,并在添加它后立即使用以下命令运行捆绑器:
这将与上面的“gem install”命令执行相同的操作。第一次运行它后,运行捆绑程序时不再需要使用“env ARCHFLAGS =“-arch x86_64””。
A few other notes to add to your instructions:
There is a good post at Russ Brooks Blog on installation which validates much of what you have above.
There are a set of admin tools available at pgadmin.org which will allow you to browse your database through a simple GUI on the Mac
If you use the admin tools you should install the instrumentation pack with the following:
where the exact command obviously depends on the version of postgresql you are using.
If you are using postgres with rails and bundler then make sure the "pg" gem is in your gem file and run bundler with the following command immediately after you add it:
This will do the same as your 'gem install' command above. After you run it for the first time you no longer need to use the 'env ARCHFLAGS="-arch x86_64"' when you run bundler.
我很幸运直接从网站下载并安装它:
http://www.postgresql.org/download/macosx
I had luck downloading and installing it straight from the site:
http://www.postgresql.org/download/macosx
我已经使用 MacPorts 来安装我的大多数服务器/低级程序(PostgreSQL、MySQL 等) .)。如果您选择走这条路,则可以按照此 关于通过 MacPorts 在 Mac 上安装 PostgreSQL 的博客文章/教程。 PostgreSQL 链接上需要注意的一件事:按照说明进行操作时,将 83 的实例更改为 90。例如,您将在他的步骤中看到这一点:
您可以改为输入此内容来获取最新版本的 PostgreSQL
我还建议您获取诸如 Navicat for PostgreSQL Lite 之类的程序。管理本地 PostgreSQL 数据库是免费的,而且很好。
如果您不想使用 MacPorts,有一个类似的替代方案,称为 HomeBrew,它非常流行......我只是懒得从 MacPorts 切换:)。
I have used MacPorts for most of my server/low level program installations (PostgreSQL, MySQL, etc.). If you choose to go that route, you can then follow this blog post/tutorial on installing PostgreSQL via MacPorts onto your Mac. One thing to note on the PostgreSQL link: when following along, change the instances of 83 to 90. For example, you will see this in his steps:
You can instead, type this to get the newest version of PostgreSQL
I would also recommend grabbing a program such as Navicat for PostgreSQL Lite. It's free and nice to have to manage your local PostgreSQL DBs.
If you don't want to go with MacPorts, there's a similar alternative called HomeBrew that's quite popular ... I'm just too lazy to switch from MacPorts :).