在windows下安装mysql2时出错

发布于 2024-12-17 18:30:00 字数 2234 浏览 3 评论 0原文

奇怪的是我可以用这个命令安装 mysql2: $ gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\ Program Files\MySQL\MySQL Server 5.5\include"' 以下是结果:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

但是当我运行 bundle install (显然我有很多 gems 需要安装)时,它安装mysql2失败,所以 bundle install 停在那里,这真的让我发疯......有人可以帮忙吗?非常感谢! 以下是捆绑安装的结果:

Installing mysql2 (0.3.8) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        c:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
checking for main() in -llibmysql... 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=c:/Ruby192/bin/ruby
        --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-libmysqllib
        --without-libmysqllib


Gem files will remain installed in G:/Desktop/20090319-/Rails Examples/ClockingI
T/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.8 for inspection.
Results logged to G:/Desktop/20090319-/Rails Examples/ClockingIT/vendor/bundle/r
uby/1.9.1/gems/mysql2-0.3.8/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.8), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.8'` succeeds before bundling.

It's strange the I can install mysql2 with this command:
$ gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"' Following is the results:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

But when I'm running bundle install (apperently I have a lot of gems needs to install), it is failed to install mysql2, so bundle install stopped there, that really drives me crazy... anyone could help? a tons of thanks!
Below is the result from bundle install:

Installing mysql2 (0.3.8) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        c:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
checking for main() in -llibmysql... 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=c:/Ruby192/bin/ruby
        --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-libmysqllib
        --without-libmysqllib


Gem files will remain installed in G:/Desktop/20090319-/Rails Examples/ClockingI
T/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.8 for inspection.
Results logged to G:/Desktop/20090319-/Rails Examples/ClockingIT/vendor/bundle/r
uby/1.9.1/gems/mysql2-0.3.8/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.8), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.8'` succeeds before bundling.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

聽兲甴掵 2024-12-24 18:30:00

在我的 ubuntu 机器上,必须先运行 apt-get install libmysqld-dev ,然后运行 ​​gem install mysql2 ......它就像一个魅力:)

On my ubuntu machine, had to run apt-get install libmysqld-dev first, then gem install mysql2 ... it worked like a charm :)

止于盛夏 2024-12-24 18:30:00

尝试从捆绑包外部安装 mysql,如果有效,请从 Gemfile 中删除 mysql

 sudo gem install mysql --no-rdoc --no-ri -- 

--with-mysql-config=/usr/local/mysql/bin/mysql_config

另外

apt-get install libmysqld-dev

Try this installing mysql from outside the bundle and if it works remove mysql from Gemfile

 sudo gem install mysql --no-rdoc --no-ri -- 

--with-mysql-config=/usr/local/mysql/bin/mysql_config

Also

apt-get install libmysqld-dev
风渺 2024-12-24 18:30:00

您尝试安装的 mysql2 gem 版本在 Windows 上有问题。

请安装mysql2 gem,无需注明版本:

gem install mysql2

The version of mysql2 gem you're trying to install have issues on Windows.

Please install mysql2 gem without indicating the version:

gem install mysql2
何其悲哀 2024-12-24 18:30:00

工作正常,请下载版本 mysql-connector-c-6.1.5-win32,解压到文件夹,然后尝试此操作。

对我来说效果很好。

gem install mysql2 --no-ri --no-rdoc --platform=ruby -- --with-mysql-include=C:\mysql-connector\mysql-connector-c-6.1.5-win32\include -- with-mysql-lib=C:\mysql-connector\mysql-connector-c-6.1.5-win32\lib

Works fines, please download the version mysql-connector-c-6.1.5-win32, unzip on the folder, and try this.

Works well for me.

gem install mysql2 --no-ri --no-rdoc --platform=ruby -- --with-mysql-include=C:\mysql-connector\mysql-connector-c-6.1.5-win32\include --with-mysql-lib=C:\mysql-connector\mysql-connector-c-6.1.5-win32\lib

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文