在 Snow Leopard 上设置 Rails 3.1 和 Postgresql

发布于 2024-12-09 05:48:11 字数 191 浏览 1 评论 0原文

我花了无数个小时尝试在我的 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 技术交流群。

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

发布评论

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

评论(5

So要识趣 2024-12-16 05:48:11

好吧,我必须以新的心态做更多的研究,现在我能够自己解决问题了。这是解决方案:

使用此命令安装 Homebrew:

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

安装后在终端中写入以下内容:

brew install postgres

如果这是您第一次安装(我就是这种情况),则在执行上述步骤后在终端中键入以下内容:

$ initdb /usr/local/var/postgres

要启动 postgresql,请键入以下内容终端:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

在上述步骤之后键入:

ps auxwww | grep postgres

如果上述命令在终端中的结果如下所示,则表示 postgresql 已正确安装:

26000   0.0  0.1  2445860   1556   ??  Ss    1:59AM   0:00.05 postgres: autovacuum launcher process
25999   0.0  0.0  2445728    512   ??  Ss    1:59AM   0:00.15 postgres: wal writer process
25998   0.0  0.0  2445728    912   ??  Ss    1:59AM   0:00.21 postgres: writer process  

25996   0.0  0.1  2445728   2508   ??  S     1:59AM   0:00.15 /usr/local/Cellar/postgresql/9.0.4/bin/postgres -D /usr/local/var/postgres

26257   0.0  0.0  2435548      0 s000  R+    2:19AM   0:00.00 grep postgres

创建用户和数据库:

createuser username

createdb -Ousername -Eutf8 databasename

要登录 postgresql,请使用此命令:

psql -U username databasename

如果你是将它与 Rails 一起使用,您可以像这样安装 gem:

sudo env ARCHFLAGS="-arch x86_64" gem install --no-ri --no-rdoc pg

如果您想停止 PostgreSQL 服务,请使用此命令:

pg_ctl -D /usr/local/var/postgres stop -s -m fast

希望这将帮助其他人节省像我一样通过不同资源来获得解决方案的时间:)

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 :

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

Once installed write this in your terminal :

brew install postgres

If this is your first install ( which was the case with me ) than type this in terminal after the above step:

$ initdb /usr/local/var/postgres

To start the postgresql type this in terminal:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

After the above step type this :

ps auxwww | grep postgres

If the result of the above command in terminal looks like this than that means the postgresql is installed correctly :

26000   0.0  0.1  2445860   1556   ??  Ss    1:59AM   0:00.05 postgres: autovacuum launcher process
25999   0.0  0.0  2445728    512   ??  Ss    1:59AM   0:00.15 postgres: wal writer process
25998   0.0  0.0  2445728    912   ??  Ss    1:59AM   0:00.21 postgres: writer process  

25996   0.0  0.1  2445728   2508   ??  S     1:59AM   0:00.15 /usr/local/Cellar/postgresql/9.0.4/bin/postgres -D /usr/local/var/postgres

26257   0.0  0.0  2435548      0 s000  R+    2:19AM   0:00.00 grep postgres

Create a user and database:

createuser username

createdb -Ousername -Eutf8 databasename

To login to postgresql use this command:

psql -U username databasename

If you are using it with rails you can install the gem like this :

sudo env ARCHFLAGS="-arch x86_64" gem install --no-ri --no-rdoc pg

If you would like to stop the PostgreSQL service use this command :

pg_ctl -D /usr/local/var/postgres stop -s -m fast

Hope this will help others in saving the time of going through different resources to come with the solution like I did :)

送君千里 2024-12-16 05:48:11

尝试使用灰姑娘。这将在 ~/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:

夏夜暖风 2024-12-16 05:48:11

需要添加到您的说明中的其他一些注释:

Russ Brooks 安装博客,它验证了您上面的大部分内容。

pgadmin.org 提供了一组管理工具,可让您通过简单的 GUI 浏览数据库Mac

如果您使用管理工具,您应该使用以下命令安装工具包:

psql -d postgres < /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql

其中确切的命令显然取决于您正在使用的 postgresql 版本。

如果您将 postgres 与 Rails 和捆绑器一起使用,请确保“pg”gem 位于您的 gem 文件中,并在添加它后立即使用以下命令运行捆绑器:

env ARCHFLAGS="-arch x86_64" bundle install

这将与上面的“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:

psql -d postgres < /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql

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:

env ARCHFLAGS="-arch x86_64" bundle install

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.

银河中√捞星星 2024-12-16 05:48:11

我很幸运直接从网站下载并安装它:

http://www.postgresql.org/download/macosx

I had luck downloading and installing it straight from the site:

http://www.postgresql.org/download/macosx

短叹 2024-12-16 05:48:11

我已经使用 MacPorts 来安装我的大多数服务器/低级程序(PostgreSQL、MySQL 等) .)。如果您选择走这条路,则可以按照此 关于通过 MacPorts 在 Mac 上安装 PostgreSQL 的博客文章/教程。 PostgreSQL 链接上需要注意的一件事:按照说明进行操作时,将 83 的实例更改为 90。例如,您将在他的步骤中看到这一点:

sudo port install postgresql83 postgresql83-server

您可以改为输入此内容来获取最新版本的 PostgreSQL

sudo port install postgresql90 postgresql90-server

我还建议您获取诸如 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:

sudo port install postgresql83 postgresql83-server

You can instead, type this to get the newest version of PostgreSQL

sudo port install postgresql90 postgresql90-server

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 :).

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