【问题标题】:MYSQL Installation Troubles [closed]MYSQL安装麻烦[关闭]
【发布时间】:2010-09-26 03:13:17
【问题描述】:

在我的 mac 上通过终端升级了一些 gem 之后,我创建了一个由 mysql 数据库备份的新 rails 项目。启动应用程序后,会出现常规欢迎登机页面。

这是问题所在 - 我尝试单击标题为“关于您的应用程序环境”的链接,我在浏览器中收到以下输出:

MissingSourceFile in Rails/infoController#properties
no such file to load -- mysql

我也在终端收到这个输出

The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
Processing Rails::InfoController#properties (for 127.0.0.1 at 2008-12-09 20:41:41) [GET]
Processing Rails::InfoController#properties (for 127.0.0.1 at 2008-12-09 20:41:41) [GET]
MissingSourceFile (no such file to load -- mysql):
...

正如它所说,我在停止应用程序后尝试发出“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/mymac/.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 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
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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


Gem files will remain installed in /Users/mymac/.gem/ruby/1.8/gems/mysql-2.7 for inspection.
Results logged to /Users/mymac/.gem/ruby/1.8/gems/mysql-2.7/gem_make.out

显然我的mysql安装有问题,因为我也尝试运行rake命令来创建数据库,提示我如下。

!!! 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 --version”时,mysql 已安装!

mysql  Ver 14.12 Distrib 5.0.67, for apple-darwin9.4.0 (i686) using readline 5.1

我也尝试过发出“sudo gem install mysql”,但这也无济于事:

sudo gem install mysql
Password:
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 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 /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out

我还尝试按照 bradheintz 的指示发出“sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config”,它似乎已经安装好,但在尝试查看之后再次应用程序环境,没有出现 ajaxy 下拉菜单,rails 应用程序完全停止!下面的输出是在应用程序决定对我死去之前打印出来的,哈哈。

dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Expected in: dynamic lookup

dyld: Symbol not found: _mysql_init
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Expected in: dynamic lookup

Trace/BPT trap

如果有人能理解这里发生了什么,以及如何解决这个问题,我将非常感激:)

【问题讨论】:

    标签: mysql ruby-on-rails macos installation


    【解决方案1】:

    问题在于 MySQL gem 构建本地扩展,并且需要系统特定的信息来了解在哪里可以找到某些库。您必须在命令行中提供此信息。

    查看this page - 重要的一点(无论如何对我有用)是:

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

    当然,请务必为您自己的系统替换正确的路径。

    另外,坚持通过sudo 运行gem install 命令。

    更大的问题是 gem 软件没有提供任何反馈,因为您不能像使用其他所有 gem 一样只做 gem install mysql (事实上,曾经能够使用 MySQL gem)。

    【讨论】:

    • 那里没有说明,这家伙安装mysql还是有问题。
    • 嗯,正是这个页面让我不解。我将进行编辑以更清楚地了解魔法。
    • 刚试了那个mate,mysql安装正常,但是现在rails应用完全停止了(见上面详细帖子的结尾)。
    • 嗯 - 这个问题对我来说是新的。但是谷歌在 Leopard 上发现了有类似问题的人,这个人声称已经修复了它:cho.hapgoods.com/wordpress/?p=158 这是谷歌搜索dyld: lazy symbol binding failed: Symbol not found: _mysql_init rails leopard 的第二次点击。
    • 我意识到在这些事情上我仍然是个菜鸟,所以我应该用哪个目录替换这个命令?
    【解决方案2】:

    尝试仅强制构建 32 位版本(假设您使用的是 Intel Mac,带有 gem 的 -V 应该会给您更详细的输出)

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

    此博文中的更多信息:http://blog.pastie.org/2008/10/mysql-64-bit-ruby-32-bit-friends-again.html

    【讨论】:

      【解决方案3】:

      上次我看到这个错误是在我尝试安装 mysql/ruby 适配器时。 在 Mac 上将 rails 升级到 rails 1.2.2 后我遇到了同样的错误,因为 1.2.2 默认删除了 mysql gem。

      我上次找到的原因是缺少 mysql 客户端或库。以 Redhat 为例,你可以到这个链接,安装 mysql 客户端和库。 http://dev.mysql.com/downloads/mysql/5.0.html#linux-rhel5-x86-32bit-rpms

      让我知道结果。

      乔

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多