开发者

How to install mysql and ruby and mysql/ruby on Mac OS X 10.6.6

开发者 https://www.devze.com 2023-02-10 18:42 出处:网络
How can I install mysql and ruby and mysql/ruby on Mac OS X 10.6.6? I\'m getting this error: checking for mysql_query() in -lmysqlclient... no

How can I install mysql and ruby and mysql/ruby on Mac OS X 10.6.6? I'm getting this error:

 checking for mysql_query() in -lmysqlclient... no

 ld: warning开发者_StackOverflow社区: in /usr/local/mysql/lib/libmysqlclient.dylib, 
     file was built for unsupported file format which is not the
     architecture being linked (i386)


Go to http://macruby.org/downloads.html and download and install http://macruby.org/files/MacRuby%200.8.zip.

Go to http://mysql.com/downloads/mysql/ and download Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive.

Go to http://tmtm.org/en/mysql/ruby/ and follow steps to download, then:

  1. run command: ruby extconf.rb --with-mysql-config
  2. modify file "Makefile" in text editor and remove all i386 architecture flags i.e. "-arch i386"
  3. run command: make
  4. run command: make install
  5. run command: export rvm_archflags="-arch x86_64"
  6. run command: export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
  7. run command: ruby test.rb
  8. run command: ruby ./test.rb -- [hostname [user [passwd [dbname [port [socket [flag]]]]]]]

Note:

If you get error like 'libmysqlclient not found' when testing, you need to specify the directory in which the library is located so that make can find it.

% env LD_RUN_PATH=libmysqlclient.so directory make

Example:

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's Hivelogic is great for this: http://hivelogic.com/articles/compiling-mysql-on-snow-leopard and http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard. Although Snow Leopard already has Ruby 1.8.7.

0

精彩评论

暂无评论...
验证码 换一张
取 消