问题描述
我正在尝试将 MySQL 安装到最新版本,因为某些安装出现问题.我运行命令 gem install mysql
并收到以下信息:
I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line. I run the command gem install mysql
and I receive the following:
构建原生扩展.这可能需要一段时间... 错误:错误安装 mysql: 错误: 失败构建 gem 原生扩展.
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/rubyextconf.rb extconf.rb:4:警告:不安全的世界可写目录/usr/bin在 PATH 中,模式 040777 extconf.rb:4:警告:不安全的世界可写目录PATH 中的/usr/bin,模式 040777extconf.rb:7:警告:不安全的世界PATH 模式下的可写目录/usr/bin040777 mkmf.rb 找不到头文件红宝石在/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:7: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem 文件将继续安装在/图书馆/Ruby/Gems/1.8/gems/mysql-2.8.1供检查.结果记录到/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
我已经搜索并尝试了很多东西,从安装特定版本到尝试重新安装 ruby,但没有任何运气.
I've searched, and tried a whole host of things, from installing specific versions to trying to reinstall ruby without any luck.
我可能会出错的任何想法?
Any ideas where I may be going wrong?
我正在尝试将 MySQL 安装到最新版本,因为某些安装出现问题.我运行命令 gem install mysql
并收到以下信息:
I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line. I run the command gem install mysql
and I receive the following:
构建原生扩展.这可能需要一段时间... 错误:错误安装 mysql: 错误: 失败构建 gem 原生扩展.
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/rubyextconf.rb extconf.rb:4:警告:不安全的世界可写目录/usr/bin在 PATH 中,模式 040777 extconf.rb:4:警告:不安全的世界可写目录PATH 中的/usr/bin,模式 040777extconf.rb:7:警告:不安全的世界PATH 模式下的可写目录/usr/bin040777 mkmf.rb 找不到头文件红宝石在/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:7: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem 文件将继续安装在/图书馆/Ruby/Gems/1.8/gems/mysql-2.8.1供检查.结果记录到/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
我已经搜索并尝试了很多东西,从安装特定版本到尝试重新安装 ruby,但没有任何运气.
I've searched, and tried a whole host of things, from installing specific versions to trying to reinstall ruby without any luck.
我可能会出错的任何想法?
Any ideas where I may be going wrong?
编辑:我从 Snow Leopard DVD 上安装了 XCode,错误只是稍微更改为以下内容:
EDIT: I installed XCode off my Snow Leopard DVD and the error just changed slightly to the following:
构建原生扩展.这可能需要一段时间...错误:安装mysql时出错:错误:无法构建 gem 原生扩展.
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.rbextconf.rb:4:警告:PATH 中不安全的世界可写目录/usr/bin,模式 040777extconf.rb:4:警告:PATH 中不安全的世界可写目录/usr/bin,模式 040777extconf.rb:7:警告:PATH 中不安全的世界可写目录/usr/bin,模式 040777extconf.rb:17:警告:PATH 中不安全的世界可写目录/usr/bin,模式 040777检查 -lmysqlclient 中的 mysql_query()... 否检查 -lm 中的 main()... 是检查 -lmysqlclient 中的 mysql_query()... 否检查 -lz 中的 main() ......是的检查 -lmysqlclient 中的 mysql_query()... 否检查 -lsocket 中的 main()... 否检查 -lmysqlclient 中的 mysql_query()... 否检查 -lnsl 中的 main()... 否检查 -lmysqlclient 中的 mysql_query()... 否检查 -lmygcc 中的 main() ... 否检查 -lmysqlclient 中的 mysql_query()... 否* extconf.rb 失败 *由于某种原因无法创建 Makefile,可能缺少必要的库和/或头文件.查看 mkmf.log 文件了解更多信息细节.您可能需要配置选项.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:4: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:7: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 extconf.rb:17: warning: Insecure world writable dir /usr/bin in PATH, mode 040777 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.
提供的配置选项:--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--没有-make-prog--srcdir=.--curdir--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby--with-mysql-config--没有-mysql-config--with-mysql-dir--没有-mysql-dir--with-mysql-include--without-mysql-include=${mysql-dir}/include--with-mysql-lib--without-mysql-lib=${mysql-dir}/lib--with-mysqlclientlib--没有-mysqlclientlib--with-mlib--没有-mlib--with-mysqlclientlib--没有-mysqlclientlib--with-zlib--没有-zlib--with-mysqlclientlib--没有-mysqlclientlib--with-socketlib--不带socketlib--with-mysqlclientlib--没有-mysqlclientlib--with-nsllib--没有-nsllib--with-mysqlclientlib--没有-mysqlclientlib--with-mygcclib--没有-mygcclib--with-mysqlclientlib--without-mysqlclientlib
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 --with-mygcclib --without-mygcclib --with-mysqlclientlib --without-mysqlclientlib
Gem 文件将继续安装在/Library/Ruby/Gems/1.8/gems/mysql-2.8.1 中以供检查.结果记录到/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
在命令行上执行which mysql"不会返回任何内容,这意味着它无法识别它.我还安装了 MySQL 系统首选项选项,我无法阻止 MySQL 运行.现在我完全不知道该怎么办了!
doing "which mysql" on the command line returns nothing, which means it's not recognizing it. I also installed the MySQL system preferences option, and I can't stop MySQL from running. Now I'm completely stuck as what to do!
编辑编辑
我刚刚使用本指南完全重新安装了 MySQL http://hivelogic.com/articles/installing-mysql-on-mac-os-x
I've just completely reinstalled MySQL using this guide http://hivelogic.com/articles/installing-mysql-on-mac-os-x
不幸的是,这也不起作用,我仍然收到相同的错误.我什至不能在命令行中执行 mysql -uroot,我收到以下错误:
Unfortunately this didn't work either, I still receive the same errors. I can't even do mysql -uroot at the command line, I get the error of:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
所以我想我什么都试过了.
So I think I've tried everything.
**已解决*
抱歉,这不起作用的原因是 MySQL 路径.我在这里写过博客:http://www.kieransenior.co.uk/2010/02/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard/
Sorry guys, the reason for this not working was because of the MySQL paths. I've blogged on it here: http://www.kieransenior.co.uk/2010/02/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard/
推荐答案
在 OSX 上安装 mysql gem
在终端中..首先执行'locate mysql_config'然后将以下命令中的路径替换为该文件所在的位置.
in a terminal.. First do a ‘locate mysql_config’ and then replace the path in the following command with where that file is.
$ sudo gem install mysql -- —–with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.7
1 gem installed
这篇关于MySQL 安装:错误:无法构建 gem 原生扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!