Rails、MySQL和雪豹

Rails、MySQL和雪豹,mysql,ruby-on-rails,ruby,osx-snow-leopard,Mysql,Ruby On Rails,Ruby,Osx Snow Leopard,我用WWDC的光盘升级到了雪豹 尝试运行我的一些rails应用程序现在会抱怨sql (in /Users/coneybeare/Projects/Ambiance/ambiance-server) !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. Importing all sound

我用WWDC的光盘升级到了雪豹

尝试运行我的一些rails应用程序现在会抱怨sql

    (in /Users/coneybeare/Projects/Ambiance/ambiance-server)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
Importing all sounds in /Users/coneybeare/Projects/Ambiance/ambiance-sounds/Import 32/Compressed/

 -- AdirondackPeepers.caf
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
dlopen(/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib
  Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Reason: image not found - /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

(See full trace by running task with --trace)
我可以发誓我以前修过一次。问题是

sudo gem install mysql
不工作,并给出错误信息:

 Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no


Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

有人让mysql在雪豹上使用rails了吗?如果是这样,您的设置是什么?更好的是,我可以做些什么来重现它?

我已经多次看到这个问题。几乎每次我在机器上构建mysql。我认为,您必须将mysqlconfig作为gem安装命令的一部分传递

sudo gem install mysql -- --with-mysql-config=/your/mysql/config

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-mysql-config

请记住,您需要mysql开发文件才能构建这个gem。

我想在这里回答我自己的问题。似乎问题不在mysql中,而是在mysql ruby绑定中。我明白了这一点,因为当我连接Querius(我的mysql gui)时,它能够连接

以下是如何从源代码构建修复绑定:

cd /tmp
wget http://www.tmtm.org/en/ruby/mysql/ruby-mysql-0.2.6.tar.gz
tar xvfz ruby-mysql-0.2.6.tar.gz
cd ruby-mysql-0.2.6
./configure
make
sudo make install

有很多库,我将不得不建立从源代码上的雪豹,他们不断弹出。MacPorts似乎没有为所有LIB进行足够的更新,所以我自己去做了。下一步:freetype()

我像这篇文章()中解释的那样进行,现在一切正常


记住要注意他安装mysql驱动程序的命令中的拼写错误。

我为此奋斗了很长一段时间,终于在雪豹上实现了。最后我从源代码安装了Ruby、RubyGems和MySQL(请参阅安装Ruby和RubyGems的说明。MySQL教程链接在底部)。我终于得到了安装的宝石,但我仍然得到

dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: /Library/Ruby/Site/1.8/universal-darwin10.0/mysql.bundle
  Expected in: flat namespace

dyld: Symbol not found: _mysql_init
  Referenced from: /Library/Ruby/Site/1.8/universal-darwin10.0/mysql.bundle
  Expected in: flat namespace

Trace/BPT trap
我终于删除了
mysql.bundle
(我不知道这是干什么用的),一切都正常了

sudo rm -f /Library/Ruby/Site/1.8/universal-darwin10.0/mysql.bundle

希望这对其他人有所帮助。

将mysql重建为64位版本或安装64位版本很重要,但您还需要确保将mysql gem的本机部分也构建为64位版本(如果您使用的是原始Intel Core Duo Mac,则不适用此要求)

下面是神奇的命令:

env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

每当您在雪豹上使用本机组件安装gem时,您应该如上所示设置ARCHFLAGS。

我也经历了同样的痛苦。。。以下是对我有效的方法:

  • 从MySQL.com下载/安装64位MySQL 5.1.37
  • 运行以下命令:
  • sudogem更新——系统 sudo env ARCHFLAGS=“-arch x86_64”gem安装mysql--with mysql config=/usr/local/mysql/bin/mysql_config
    我还卸载了我10.5天的所有mysql gems,如果上面的内容对你不起作用,我可能会这样做:)

    我也有同样的问题,下面是我的工作

  • 安装雪豹和64位MySQL DMG

  • 创建/etc/my.cnf以指向我以前的MySQL数据目录(如上所述),然后运行

    sudo MySQL\u升级

  • 打开IRB并使用(通过blog.costan.us/2009/07/rebuild your ruby gems,如果您更新到.html)重新安装我的所有gem

  • 卸载了我安装的MySQL gems

  • 使用

    sudo env ARCHFLAGS=“-arch x86_64”gem安装MySQL--with MySQL config=/usr/local/MySQL/bin/MySQL_config

  • 有了这些,到目前为止一切似乎都在运转*敲打木头*

    安装雪豹后,我的配置无法正常工作。我在上找到了MAMP,它捆绑了Apache、PHP和MySQL。你像安装应用程序一样安装它,它就可以正常工作。也许值得一试,而且是免费的


    mesh

    我尝试了很多次archflags技巧,但都有一些细微的变化,但对我来说根本不起作用

    最终的工作是切换回与雪豹一起安装的ruby和gem版本

    我已经建立并安装了我自己的版本,除了这个版本,它在各个方面都对我有效。
    由于其他一切似乎都很好,我不禁猜测mysql插件中有一些古怪的假设。无论如何,我所做的只是切换/usr/bin再次成为我的第一个路径。我在/usr/local/ruby-1.8.7和/usr/local/ruby-1.9.1中安装了ruby,以便能够轻松切换。我想我会提到它,因为archflags解决方案似乎适用于许多人,但不是所有人。

    我将mysql\u config程序从$mysql\u HOME/bin重命名为其他名称,以便gem安装程序中的配置脚本无法找到它。即使我使用的是libs选项,gem安装程序也总是使用mysql安装中的编译设置,这是胖二进制的。但是默认的ruby安装只有x86_64,因此gem的编译失败。重命名mysql_config程序后,以下命令工作正常,并安装了gem:

    sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local/mysql
    

    这篇文章为我解决了这个问题:)

    • 先于豹

      sudogem安装mysql--with mysql dir=/usr/local/mysql

      • PPC机器上的Leopard:

        sudo env ARCHFLAGS=“-arch ppc”gem安装mysql--with mysql config=/usr/local/mysql/bin/mysql\u config

      • Intel计算机上的Leopard:

        sudo env ARCHFLAGS=“-arch i386”gem安装mysql--with mysql config=/usr/local/mysql/bin/mysql\u config

      • 雪豹(仅限英特尔):

        sudo env ARCHFLAGS=“-arch x86_64”gem安装mysql--with mysql config=/usr/local/mysql/bin/mysql_config


    如果要使用RVM安装mysql gem,则需要使用以下代码来安装它

    sudo env ARCHFLAGS="-arch x86_64" gem install mysql
    

    这个方法在Leopard Server中对我很有效,上面的方法都不起作用

    如果您使用bundler,您可以使用“bundle config”为mysql设置正确的构建参数,如下所示:

    bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
    

    有关设置ARCHFLAGS和传递--mysql config=。。。似乎不足以为我解决这个问题
    bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
    
    DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
    
     sudo gem uninstall mysql 
    
     find /usr -name 'mysql_config' 
    
     sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/bin/mysql_config 
    
    user$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
    
    user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    
    user$ source .bash_profile
    
    user$ rvm install 1.9.2
    user$ rvm use 1.9.2
    
    user$ rvm gemset create rails30x
    user$ rvm 1.9.2@rails30x
    
    user$  gem install rails -v 3.0.x.
    
    basedir=
    datadir=
    
    basedir=/usr/local/mysql-version-name
    datadir=/usr/local/mysql-version-name/data
    
    export DYLD_LIBRARY_PATH=/usr/local/mysql-version-name/lib:$DYLD_LIBRARY_PATH
    
    user$ gem install mysql2 -v 0.2.7 
    
    user$ rails new appname
    
    development: 
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: appname_development
      pool: 5
      username: username
      password: pwd
      host: localhost