維尼的蜂巢

RealTime??!! It’s amazing!!!!

Ruby, Rails and MySQL with Leopard 10.5.2 and XCode 3.0 七月 13, 2009

Filed under: Mac,Rails — kevinlin @ 8:20 下午
Tags:

其實本來用MAMP(apache+mysql)跟Locomotive(ruby,rails)
這樣是可以run的

但是我想要解決為什麼我的mysql跟rails就是連接有問題

上一篇似乎解決了安裝gem mysql但是…
還是有錯誤

上網找了一下 發現原來是XCode裝的Ruby搞的鬼

解決方法是給多點參數,然後rebuild一下gem的mysql

1. 先打mysql_config可以看到一些參數
lin-kevinde-macbook:music_library Kevin$ mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
–cflags [-I/usr/local/mysql/include -g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL]
–include [-I/usr/local/mysql/include]
–libs [-L/usr/local/mysql/lib -lmysqlclient -lz -lm -lmygcc]
–libs_r [-L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc]
–plugindir [/usr/local/mysql/lib/plugin]
–socket [/tmp/mysql.sock]
–port [0]
–version [5.1.36]
–libmysqld-libs [-L/usr/local/mysql/lib -lmysqld -ldl -lz -lm -lmygcc]

2. 把cflags的都複製起來,放到ARCHFLAGS裡
sudo env ARCHFLAGS="-g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL" gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config

3.然後去/Library/Ruby/Gems/1.8/gems/mysql-*/
再打下面這堆
sudo env ARCHFLAGS="-g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL" ruby extconf.rb –with-mysql-include=/usr/local/mysql/include –with-mysql-lib=/usr/local/mysql/lib –with-mysql-dir=/usr/local/mysql –with-mysql-config=/usr/local/mysql/bin/mysql_config

4. 接著就
make
make install 就成功了

參考 http://cho.hapgoods.com/wordpress/?p=158

ps.其實我本來是裝64bit的mysql照著這樣的步驟都不能成功,改裝32bit的mysql就成功了,真奇怪

 

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s