【问题标题】:Unable to install MySQL on Mac OS X无法在 Mac OS X 上安装 MySQL
【发布时间】:2011-01-02 03:41:49
【问题描述】:

我遇到了这个问题中描述的确切问题:MYSQL Installation Troubles。不幸的是,没有一个答案对我有帮助(而且它已关闭)。

我尝试学习 Ruby on Rails,但没有让 MySQL 工作(因此它与编程相关)。

我输入:rake db:create 并得到:

!!!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!
no such file to load -- mysql

(See full trace by running task with --trace)
HD-Auckland:shoutbox max$ gem install mysql
WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
      /usr/bin aren't both writable.
WARNING:  You don't have /Users/max/.gem/ruby/1.8/bin in your PATH,
      gem executables will not run.
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
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
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Gem files will remain installed in /Users/max/.gem/ruby/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Users/max/.gem/ruby/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

所以正如它告诉我的那样,我尝试了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
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
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

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=/opt/local/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib


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

我也试过这个命令sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config,得到了同样的错误!

我能做什么?我只想将我的数据库迁移到 MySQL 服务器!

感谢您的帮助,Mexx

更新:

感谢大家的好评!是的,我在雪豹上。 我从这里http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg 下载了mysql并安装了它。 然后我按照 Hivelogic 的 mysql 安装指南进行操作。

当我现在输入:sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_configsudo gem istall mysqlsudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

我会得到:

Building native extensions.  This could take a while...
fotoSuccessfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...

No definition for next_result

No definition for field_name

No definition for field_table

No definition for field_def

No definition for field_type

No definition for field_length

No definition for field_max_length

No definition for field_flags

No definition for field_decimals

No definition for time_inspect

No definition for time_to_s

No definition for time_get_year

No definition for time_get_month

No definition for time_get_day

No definition for time_get_hour

No definition for time_get_minute

No definition for time_get_second

No definition for time_get_neg

No definition for time_get_second_part

No definition for time_set_year

No definition for time_set_month

No definition for time_set_day

No definition for time_set_hour

No definition for time_set_minute

No definition for time_set_second

No definition for time_set_neg

No definition for time_set_second_part

No definition for time_equal

No definition for error_errno

No definition for error_sqlstate
Installing RDoc documentation for mysql-2.8.1...

No definition for next_result

No definition for field_name

No definition for field_table

No definition for field_def

No definition for field_type

No definition for field_length

No definition for field_max_length

No definition for field_flags

No definition for field_decimals

No definition for time_inspect

No definition for time_to_s

No definition for time_get_year

No definition for time_get_month

No definition for time_get_day

No definition for time_get_hour

No definition for time_get_minute

No definition for time_get_second

No definition for time_get_neg

No definition for time_get_second_part

No definition for time_set_year

No definition for time_set_month

No definition for time_set_day

No definition for time_set_hour

No definition for time_set_minute

No definition for time_set_second

No definition for time_set_neg

No definition for time_set_second_part

No definition for time_equal

No definition for error_errno

No definition for error_sqlstate

rake db:create 最终会得到:

(in /Users/max/rails/shoutbox)
!!! 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!
no such file to load -- mysql

(See full trace by running task with --trace)

【问题讨论】:

  • 澄清一下,你是如何从 mysql 站点的二进制文件、fink、ports、brew 等安装 mysql 的?
  • sudo port install mysql5 +server rb-mysql 我想我做了命令,但是当你问的时候我又不确定了,所以我又做了一次,现在正在下载:/对不起,伙计们-希望我没有浪费你的时间。完成后会在这里更新。
  • 通过 macports 进行安装我收到此错误:错误:目标 org.macports.configure 返回:lipo:无法打开输入文件:/opt/local/lib/libz.dylib(没有这样的文件或目录)错误:处理过程中遇到状态 1。
  • 您可以按照 Hivelogic 的 mysql 安装指南进行安装。 hivelogic.com/articles/compiling-mysql-on-snow-leopard

标签: mysql ruby-on-rails macos installation rubygems


【解决方案1】:

出于某种原因(可能是因为我正在使用 ruby​​gems 1.3.7 或安装 mysql-2.8.1)

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

对我不起作用,所以在查看 gems/mysql-2.8.1/ext/mysql_api/extconf.rb 后,我发现 extconf.rb 在 PATH 中查找 mysql_config 所以我尝试了

export PATH=$PATH:/usr/local/mysql/bin
sudo gem install mysql

并完成了工作

【讨论】:

  • 谢谢。在雪豹上完美运行!
【解决方案2】:

你在雪豹上吗?您必须使用 x64 标头执行 C 依赖项编译,尝试:

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

【讨论】:

【解决方案3】:

我自己也遇到了 MySQL gem 的问题,这些是我实际添加书签的仅有的 2 个链接,所以其中一个应该对我有用。我想我会分享。

  1. http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard
  2. http://rapd.wordpress.com/2007/05/17/battle-against-ror-gem-install-mysql/

第二个有点旧,所以不确定它是否仍然适用。

【讨论】:

    【解决方案4】:

    为了在 OS X 上安装 MySQL gem,您需要安装安装磁盘上的 XCode 开发工具。你也可以从http://developer.apple.com下载。

    【讨论】:

      【解决方案5】:

      我只是用这个命令解决了这个问题:

       sudo env ARCHFLAGS="-arch i386" gem install --no-rdoc --no-ri mysql -v 2.8.1 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
      

      确实,我需要在运行 dmg 文件中的 mysql-5.6.2-m5-osx10.5-x86 的 mac OS X Leopard 10.5.8 上安装 mysql gem 版本 2.8.1。我遇到的问题是它找不到库并且我进行了一些操作,然后由于权限而无法安装。我找到了该命令,添加了我需要的版本并将架构更改为与我的 mysql 安装相对应的架构。

      所以如果有人仍然想安装那个版本:) 让我们试试吧!但我们可能不会经常安装这个,而且在 Leopard 上安装得更少!

      【讨论】:

        【解决方案6】:

        要使用的正确 gem 是 mysql2

        【讨论】:

          【解决方案7】:

          我遇到了同样的问题。我解决了先安装适配器:

          gem install activerecord-mysql2-adapter
          

          然后,使用 mysql2 gem 安装

          sudo gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-03-18
            • 2016-07-05
            • 2017-11-02
            • 2011-05-04
            • 2012-10-24
            • 2013-04-17
            相关资源
            最近更新 更多