MYSQL安装问题解决方案

3
在我的mac终端升级了几个gems之后,我创建了一个由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",看起来安装成功了,但在尝试再次查看应用程序环境后,没有出现Ajax下拉菜单,而且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

如果有人能理解这里发生了什么,并知道如何解决这个问题,我会非常感激 :)
3个回答

6
问题在于MySQL gem构建本地扩展,需要系统特定信息以查找某些库的位置。您必须在命令行上提供此信息。
请查看this page-重要部分(对我而言有效)是:
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
当然,请确保为自己的系统替换正确的路径。
另外,继续通过sudo运行您的gem安装命令。
更大的问题是,gem软件没有提供有关无法像使用其他gem一样执行gem install mysql(事实上,曾经可以使用MySQL gem)的反馈。

那里没有任何说明,那个人仍然在安装mysql时遇到麻烦。 - Damian
好的,就是那个页面让我摆脱了困境。我会编辑一下,以便更清楚地解释其中的奥妙。 - bradheintz
刚试了一下,朋友,mysql 安装成功了,但现在 Rails 应用程序完全停止了(请参见上面详细帖子的结尾)。 - Damian
嗯 - 这个问题对我来说是新的。但是谷歌上有人在Leopard上遇到了类似的问题,这个人声称已经解决了:http://cho.hapgoods.com/wordpress/?p=158这是从谷歌搜索“dyld: lazy symbol binding failed: Symbol not found: _mysql_init rails leopard”中得到的第二个结果。 - bradheintz
我意识到在这些事情上我还是个新手,所以我应该用哪个目录来替换这个命令? - Damian

0

我上次看到这个错误是在尝试安装mysql/ruby适配器时。而且在将Mac上的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

请告诉我结果。

Joe


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接