[英]How to install mysql and ruby and mysql/ruby on Mac OS X 10.6.6
如何在Mac OS X 10.6.6上安裝mysql,ruby和mysql / ruby? 我收到此錯誤:
checking for mysql_query() in -lmysqlclient... no
ld: warning: in /usr/local/mysql/lib/libmysqlclient.dylib,
file was built for unsupported file format which is not the
architecture being linked (i386)
轉到http://macruby.org/downloads.html並下載並安裝http://macruby.org/files/MacRuby%200.8.zip 。
轉到http://mysql.com/downloads/mysql/並下載Mac OS X版本。 10.6(x86,64位),DMG存檔。
轉到http://tmtm.org/en/mysql/ruby/並按照步驟進行下載,然后:
ruby extconf.rb --with-mysql-config
"-arch i386"
make
make install
export rvm_archflags="-arch x86_64"
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
ruby test.rb
ruby ./test.rb -- [hostname [user [passwd [dbname [port [socket [flag]]]]]]]
注意:
如果在測試時出現諸如“ libmysqlclient not found
”之類的錯誤,則需要指定該庫所在的目錄,以便make可以找到它。
% env LD_RUN_PATH=libmysqlclient.so directory make
例:
my = Mysql.new(hostname, username, password, databasename)
st = my.prepare("insert into tblname (col1,col2,col3) values (?,?,?)")
st.execute("abc",123,Time.now)
st.prepare("select col1,col2,col3 from tblname")
st.execute
st.fetch # => ["abc", 123, #<Mysql::Time:2005-07-24 23:52:55>]
st.close
丹·本傑明(Dan Benjamin)的Hivelogic對此非常有用: http ://hivelogic.com/articles/compiling-mysql-on-snow-leopard和http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-雪豹 。 盡管Snow Leopard已經擁有Ruby 1.8.7。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.