简体   繁体   English

MySQL 安装:错误:无法构建 gem 原生扩展

[英]MySQL Install: ERROR: Failed to build gem native extension

I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line.由于某些安装出错,我正在尝试将 MySQL 安装到最新版本。 I run the command gem install mysql and I receive the following:我运行命令gem install mysql并收到以下信息:

Building native extensions.构建原生扩展。 This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension.这可能需要一段时间... 错误:安装 mysql 时出错:错误:无法构建 gem 原生扩展。

/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 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4:警告:PATH 中不安全的世界可写目录 /usr/bin,模式 040777 extconf.rb:4:警告:不安全的世界可写目录 /usr/bin 在 PATH,模式 040777 extconf.rb:7:警告:不安全的世界可写目录 /usr/bin 在 PATH,模式 040777 mkmf.rb 找不到 Z58E53D1324EEF9AADFZ 的 Z58E53D1324EEF6265FEDDB97B0 的 header 文件/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Gem 文件将继续安装在 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 中以供检查。 Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out结果记录到 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

I've searched, and tried a whole host of things, from installing specific versions to trying to reinstall ruby without any luck.我已经搜索并尝试了很多东西,从安装特定版本到尝试重新安装 ruby 没有任何运气。

Any ideas where I may be going wrong?有什么想法我可能会出错吗?

I'm trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line.由于某些安装出错,我正在尝试将 MySQL 安装到最新版本。 I run the command gem install mysql and I receive the following:我运行命令gem install mysql并收到以下信息:

Building native extensions.构建原生扩展。 This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension.这可能需要一段时间... 错误:安装 mysql 时出错:错误:无法构建 gem 原生扩展。

/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 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4:警告:PATH 中不安全的世界可写目录 /usr/bin,模式 040777 extconf.rb:4:警告:不安全的世界可写目录 /usr/bin 在 PATH,模式 040777 extconf.rb:7:警告:不安全的世界可写目录 /usr/bin 在 PATH,模式 040777 mkmf.rb 找不到 Z58E53D1324EEF9AADFZ 的 Z58E53D1324EEF6265FEDDB97B0 的 header 文件/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Gem 文件将继续安装在 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 中以供检查。 Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out结果记录到 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

I've searched, and tried a whole host of things, from installing specific versions to trying to reinstall ruby without any luck.我已经搜索并尝试了很多东西,从安装特定版本到尝试重新安装 ruby 没有任何运气。

Any ideas where I may be going wrong?有什么想法我可能会出错吗?

EDIT : I installed XCode off my Snow Leopard DVD and the error just changed slightly to the following:编辑:我从我的雪豹 DVD 上安装了 XCode,错误只是稍微更改为以下内容:

Building native extensions.构建原生扩展。 This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension.这可能需要一段时间... 错误:安装 mysql 时出错:错误:无法构建 gem 原生扩展。

/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 necessa /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4:警告:PATH 中不安全的世界可写目录 /usr/bin,模式 040777 extconf.rb:4:警告:PATH 中不安全的世界可写目录 /usr/bin,模式 040777 extconf.rb:7:警告:PATH 中的不安全的世界可写目录 /usr/bin,模式 040777 extconf.rb:17:警告:不安全的世界可写目录 /usr PATH 中的 /bin,模式 040777 检查 -lmysqlclient 中的 mysql_query() ... 不检查 -lm 中的 main() ... 是 检查 -lmysqlclient 中的 mysql_query() ... 不检查 - lz... 是在 -lmysqlclient 中检查 mysql_query()... 在 -lsocket 中不检查 main() ... 在 -lmysqlclient 中不检查 mysql_query() ... 在 -lnsl 中不检查 main()。 .. 不检查 -lmysqlclient 中的 mysql_query() ... 不检查 -lmygcc 中的 main() ... 不检查 -lmysqlclient 中的 mysql_query() ... 否* extconf.rb 失败 *由于无法创建 Makefile出于某种原因,可能缺乏必要性ry libraries and/or headers. ry 库和/或头文件。 Check the mkmf.log file for more details.检查 mkmf.log 文件以获取更多详细信息。 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=.提供的配置选项: --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 --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 files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Gem 文件将继续安装在 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 中以供检查。 Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out结果记录到 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

doing "which mysql" on the command line returns nothing, which means it's not recognizing it.在命令行上执行“which mysql”不会返回任何内容,这意味着它无法识别它。 I also installed the MySQL system preferences option, and I can't stop MySQL from running.我还安装了 MySQL 系统首选项选项,我无法阻止 MySQL 运行。 Now I'm completely stuck as what to do!现在我完全不知道该怎么做!

EDIT EDIT编辑编辑

I've just completely reinstalled MySQL using this guide http://hivelogic.com/articles/installing-mysql-on-mac-os-x我刚刚使用本指南http://hivelogic.com/articles/installing-mysql-on-mac-os-x 完全重新安装了 MySQL

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:我什至不能在命令行中执行 mysql -uroot ,我收到以下错误:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) ERROR 2002 (HY000): 无法通过套接字'/tmp/mysql.sock' (2) 连接到本地 MySQL 服务器

So I think I've tried everything.所以我想我已经尝试了一切。

**SOLVED* **解决了*

Sorry guys, the reason for this not working was because of the MySQL paths.抱歉,这不起作用的原因是因为 MySQL 路径。 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/我在这里写过博客: http://www.kieransenior.co.uk/2010/02/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard/

On Debian (or Ubuntu) systems, just install libmysqlclient-dev package using: 在Debian(或Ubuntu)系统上,只需使用以下命令安装libmysqlclient-dev包:

sudo apt-get install libmysqlclient-dev

and then: 然后:

gem install mysql

It will be installed without any error. 它将安装没有任何错误。

Installing the mysql gem on OSX 在OSX上安装mysql gem

in a terminal.. First do a 'locate mysql_config' and then replace the path in the following command with where that file is . 在终端中..首先执行'locate mysql_config' ,然后将以下命令中的路径替换为该文件所在的位置

$ 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

First of all you need to differentiate between the MySQL as Server, MySQL as Client and the Ruby bindings to MySQL. 首先,您需要区分MySQL作为服务器,MySQL作为客户端和Ruby绑定到MySQL。

I'm not familiar with Mac, but for *nix OS you need to install MySQL through your package manager. 我不熟悉Mac,但对于* nix OS,您需要通过软件包管理器安装MySQL。 To get the Ruby bindings installed with 要安装Ruby绑定

gem install mysql

you need the development headers of ruby (in Ubuntu it is the package ruby-dev) and the development headers of the MySQL-Client (currently libmysqlclient16-dev in Ubuntu). 你需要ruby的开发头文件(在Ubuntu中它是包ruby-dev)和MySQL-Client的开发头文件(目前在Ubuntu中是libmysqlclient16-dev )。 I don't know if they are named different on Mac, but after you got those installed the Ruby bindings should install without any error. 我不知道它们在Mac上是否有不同的名称,但是在安装完这些内容之后,Ruby绑定应该安装没有任何错误。

A number of people found this post helpful. 很多人认为这篇文章很有帮助。

Also, I needed to do first type this: 另外,我需要先做这个:

yum install mysql-devel

and then: 然后:

gem install mysql 

For some people you may need to type: 对于某些人,您可能需要键入:

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

on OSX mountain Lion: If you have brew installed, then brew install mysql and follow the instructions on creating a test database with mysql on your machine. 在OSX mountain Lion上:如果你已经安装了brew ,那么brew install mysql并按照你的机器上用mysql创建测试数据库的instructions进行instructions You don't have to go all the way through, I didn't need to After I did that I was able to bundle install and rake. 你不必一直走,我不需要在我做了之后我能够捆绑安装和耙。

In order to resolve 为了解决

Gem::Ext::BuildError: ERROR: Failed to build gem native extension error for mysql2, Gem :: Ext :: BuildError:错误:无法为mysql2构建gem原生扩展错误,

I think libmysql-ruby got changed with ruby-mysql 我认为libmysql-rubyruby-mysql改了

Simply try with following commands, 只需尝试以下命令,

sudo apt-get install ruby-mysql

& then & 然后

sudo apt-get install libmysqlclient-dev

I had also forgotten to actually install MySQL in the first place. 我也忘记了首先安装 MySQL。 Following this guide helped a lot. 遵循本指南帮助了很多。

http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/ http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/

As well as adding these lines to my .profile: 除了将这些行添加到我的.profile:

export PATH="/usr/local/mysql/bin:$PATH"
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin

I had a similar experience, so here are the things that I tried 我有类似的经历,所以这里是我尝试过的东西

Firstly, I tried to install mysql's required packages by running the command below in my terminal 首先,我尝试通过在终端中运行以下命令来安装mysql所需的软件包

sudo apt-get install build-essential libmysqlclient-dev

Secondly, I tried updating rubygems on my system by running the command below in my terminal 其次,我尝试通过在终端中运行以下命令来更新系统上的rubygems

sudo gem update --system

But I was still experiencing the same issue. 但我仍然遇到同样的问题。 After much research I realized that I was using an almost out-of-date version of the mysql gem. 经过大量研究后,我意识到我使用的是几乎过时的mysql gem版本。 I simply needed to use the mysql2 gem ( mysql2 gem )and not the mysql gem, so I fixed it by running the command below in my terminal 我只需要使用mysql2 gem( mysql2 gem )而不是mysql gem,所以我通过在终端中运行以下命令来修复它

gem install mysql2

This worked fine for me. 这对我来说很好。 Before running the last command, ensure that you've ran the first and second commands to be sure that everything is fine on your system. 在运行最后一个命令之前,请确保已运行第一个和第二个命令以确保系统上的一切正常。

That's all. 就这样。

I hope this helps 我希望这有帮助

If you use Percona Mysql server 如果你使用Percona Mysql服务器

$ yum install Percona-Server-devel-55 $ yum安装Percona-Server-devel-55

$ gem install mysql $ gem install mysql

you can try to reinstall the latest version of xcode / dev. 您可以尝试重新安装最新版本的xcode / dev。 tools for snow leopard - this should fix your errors 雪豹工具 - 这应该可以解决你的错误

如果你从源码安装这里是一个教程。如果它有帮助,请高兴http://raihan90.blogspot.com/2009/03/mysql-step-by-step-hacking-into-mysql.html

注意:你需要指定 - 键,而不是--with-mysql-config = / usr / local / mysql / bin / mysql_config

yum -y install gcc mysql-devel ruby-devel rubygems
gem install mysql2

Your Ubuntu OS need to install library for mysql client sudo apt-get install libmysqlclient-dev 您的Ubuntu OS需要为mysql客户端sudo apt-get install libmysqlclient-dev安装库

After That just install bundle or bundle install 之后,只需安装bundlebundle install

While these answers pointed me in the right direction, on Alpine linux the package I needed was mariadb-dev , eg.虽然这些答案为我指明了正确的方向,但在 Alpine linux 上,我需要的 package 是mariadb-dev ,例如。 run apk add mariadb-dev before the gem install mysql command.gem install mysql命令之前运行apk add mariadb-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gem install mysql:无法构建gem原生扩展(Mac Lion) - gem install mysql: Failed to build gem native extension (Mac Lion) 安装mysql2 gem时出错:无法构建gem原生扩展 - Error installing mysql2 gem: Failed to build gem native extension 错误:安装mysql时出错:错误:无法构建gem本机扩展 - ERROR: Error installing mysql: ERROR: Failed to build gem native extension 错误:无法构建 gem 原生扩展 - 安装 mysql2 时出错 - ERROR: Failed to build gem native extension - Error installing mysql2 错误:无法构建 gem 本机扩展(rails 3.2.3 上的 mysql2) - ERROR: Failed to build gem native extension (mysql2 on rails 3.2.3) 安装 mysql2 时出错:无法构建 gem 原生扩展 - Error installing mysql2: Failed to build gem native extension 无法在 Mysql Docker 容器中安装 mysql2 gem:无法构建 gem 本机扩展 - Cannot install mysql2 gem inside Mysql Docker container: Failed to build gem native extension mysql2 gem无法在Windows 7上安装:无法生成gem本机扩展 - mysql2 gem failing to install on Windows 7: failed to build gem native extension Ruby - Gem - mysql - 无法构建gem原生扩展 - Ruby - Gem - mysql - Failed to build gem native extension 安装mysql的Rails - 安装mysql2时出错:错误:无法构建gem原生扩展 - Rails installing mysql - Error installing mysql2: ERROR: Failed to build gem native extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM