如何在 Windows 上安装 mysql2 gem
我正在使用 DevKit 和 XAMPP,现在我必须执行以下命令:
gem install mysql2 -v 0.2.6 --platform=ruby -- --with-mysql-dir="x:\Prog
ram Files\mysql-5.5.11-winx64" --with-mysql-lib="x:\Program Files\mysql-5.5.11-winx64\lib" --with-my
sql-include="x:\Program Files\mysql-5.5.11-winx64\include" --without-opt-dir
但是,XAMPP 在其 MySQL 目录中不包含 lib
或 include
文件夹。我应该指定什么?
谢谢
I'm using DevKit and XAMPP, and now I have to execute the following command:
gem install mysql2 -v 0.2.6 --platform=ruby -- --with-mysql-dir="x:\Prog
ram Files\mysql-5.5.11-winx64" --with-mysql-lib="x:\Program Files\mysql-5.5.11-winx64\lib" --with-my
sql-include="x:\Program Files\mysql-5.5.11-winx64\include" --without-opt-dir
However, XAMPP does not include a lib
or include
folder on its MySQL directory. What should I specify instead ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这是我使用 XAMPP 的 MySQL 安装在 Windows 7 上运行的带有 MySQL2 gem 的 Ruby 的解决方案。
在 Ruby 命令提示符处运行(确保更新安装 XAMPP/MySQL 的路径):
此命令的输出包括:
================== =======
您已经安装了 mysql2 的二进制版本。
它是使用 MySQL Connector/C 版本 6.0.2 构建的。
建议使用完全相同的版本以避免潜在问题。
在构建此 gem 时,必要的 DLL 文件可用
在以下下载中:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
并把Ruby bin 目录中的 lib\libmysql.dll 文件,例如 C:\Ruby\bin
===========================
这非常重要。按照说明进行操作。下载文件,从 zip 文件内的 lib 目录中提取 libmysql.dll。
将所述 dll 复制到 Ruby 安装的 bin 文件夹中。如果您使用 RailsInstaller 并选择默认值,则目录将类似于 C:\RailsInstaller\Ruby1.9.3\bin。
Here's the solution I used to get Ruby with the MySQL2 gem running on Windows 7 using XAMPP's MySQL installation.
At the Ruby command prompt run (make sure to update the path to wherever you've got XAMPP/MySQL installed):
The output from this command includes:
=========================
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.0.2.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files where available
in the following download:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin
=========================
That is very important. Follow the instructions. Download the file, extract the libmysql.dll from the lib directory within the zip file.
Copy said dll into the bin folder for your Ruby install. If you used RailsInstaller and selected the defaults, the directory will be something like C:\RailsInstaller\Ruby1.9.3\bin.
对于任何感兴趣的人来说,这是一个合适的解决方案,它不会弄乱您当前安装的 mysql 服务器
现在运行此命令
gem 安装 mysql2 -- '--with-mysql-lib="c:\mysql-gem-install\lib\opt" --with-mysql-include="c:\mysql-gem-install\include "'
我刚刚安装了 mysql2宝石 v.0.3.7
Here is a proper solution for anyone interested, that doesn't mess up your current installation of mysql server
now run this command
gem install mysql2 -- '--with-mysql-lib="c:\mysql-gem-install\lib\opt" --with-mysql-include="c:\mysql-gem-install\include"'
I just installed mysql2 gem v. 0.3.7
我在这里找到了解决方案:
rails 3 not work with windows 7
I found the solution here:
rails 3 not working with windows 7
解决我的问题的是:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/Program Files/MySQL/MySQL Connector C 6.1 6.1.2/" '
需要注意的一个陷阱是我将反斜杠 (\) 更改为普通斜杠 (/)。我已经尝试使用反斜杠执行相同的过程,但没有成功。
安装程序已在
MySQL Connector C 6.1 6.1.2
目录中包含适用于 MySQL 的 C 连接器。因此,仅传递--with-mysql-dir
参数,而不传递--with-mysql-lib
或--with-mysql-include
> 参数,使 gem 查看同一目录中的lib
和include
目录What solved my problem was:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/Program Files/MySQL/MySQL Connector C 6.1 6.1.2/"'
One pitfall to be aware of is that I changed the backslashes (\) to normal slashes (/). I've tried the same procedure with backslashes and it didn't work.
The installer already includes the C connectors for MySQL at
MySQL Connector C 6.1 6.1.2
directory. Therefore, passing only the--with-mysql-dir
parameter without the--with-mysql-lib
or--with-mysql-include
parameters, makes the gem to look at the same directory for thelib
andinclude
directories谢谢尼克。我在 Windows 8(64 位)上也能正常工作。我从此页面获得了 MySQL 连接器: http://dev.mysql.com/downloads/connector/ c/。下载并运行安装程序。之后使用下面的命令:
现在它可以工作了
Thanks nick. I got it working too on my windows 8 (64bit). I got MySQL connector from this page: http://dev.mysql.com/downloads/connector/c/. Download and Run the installer. After that use the command below:
Now it's working
我不确定 XAMPP 是如何组织的,但是要构建 gem,您可以从 他们的网站 并将 devkit 指向那里。
之后,gem 也应该可以与 XAMPP 一起正常工作。
I'm not sure, how XAMPP is organized, but to build the gem, you could download the same version of mysql from their site and point devkit there.
After that, the gem should work fine with XAMPP as well.
您可以将 libmysql.dll 从 MySQL 或 MySQL 连接器目录的 lib 子目录复制到 ruby\bin 目录中,libmysql.dll 将位于 c:\mysql-connector-c-6.1.1-win32\lib。
You may copy libmysql.dll from the lib subdirectory of your MySQL or MySQL connector directory into your ruby\bin directory ,and libmysql.dll would be located at c:\mysql-connector-c-6.1.1-win32\lib.
使用 RubyInstaller2 和 MSYS 工具链,安装 mysql2 gem 所需要做的就是
gem install mysql2 --platform=ruby
这将自动下载并安装所需的库,然后从来源。
With RubyInstaller2, and the MSYS toolchain, all you have to do to install the mysql2 gem is
gem install mysql2 --platform=ruby
This will automatically download and install the required libraries, and then build the gem from source.