如何在 Windows 上安装 mysql2 gem

发布于 2024-11-14 04:15:29 字数 414 浏览 4 评论 0原文

我正在使用 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 目录中不包含 libinclude 文件夹。我应该指定什么?

谢谢

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 技术交流群。

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

发布评论

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

评论(8

眼泪也成诗 2024-11-21 04:15:29

这是我使用 XAMPP 的 MySQL 安装在 Windows 7 上运行的带有 MySQL2 gem 的 Ruby 的解决方案。

在 Ruby 命令提示符处运行(确保更新安装 XAMPP/MySQL 的路径):

gem install mysql2 -- --with-mysql-dir="C:\xampp\mysql\bin"

此命令的输出包括:

================== =======

您已经安装了 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):

gem install mysql2 -- --with-mysql-dir="C:\xampp\mysql\bin"

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.

电影里的梦 2024-11-21 04:15:29

对于任何感兴趣的人来说,这是一个合适的解决方案,它不会弄乱您当前安装的 mysql 服务器

  1. 下载带有 mysql 服务器 5.1 而不是 msi 的 zip 文件。确保它是 32 位而不是 64 位。 (从这里
  2. 由于没有安装程序文件,因此创建一个文件夹 c :\mysql-gem-install - 完成后您可以将其删除。
  3. 将 zip 文件中的所有文件解压到您刚刚创建的文件夹中。
  4. 现在运行此命令

    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

  1. Download a zip file with mysql server 5.1 NOT the msi one. Make sure it's 32-bit NOT 64-bit. (From here)
  2. Since there is no installer file with this, create a folder c:\mysql-gem-install - you can remove it once you finish.
  3. Extract all the files from the zip file into the folder you just created.
  4. 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

墟烟 2024-11-21 04:15:29

我在这里找到了解决方案:

rails 3 not work with windows 7

I found the solution here:

rails 3 not working with windows 7

薆情海 2024-11-21 04:15:29

解决我的问题的是:

  1. 下载了最新的 MySQL Installer for windows 7 32 位
  2. 使用以下命令安装 gem: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 查看同一目录中的 libinclude 目录

What solved my problem was:

  1. Downloaded the lastest MySQL Installer for windows 7 32 bits
  2. Installed the gem with the following command: 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 the lib and include directories

挖个坑埋了你 2024-11-21 04:15:29

谢谢尼克。我在 Windows 8(64 位)上也能正常工作。我从此页面获得了 MySQL 连接器: http://dev.mysql.com/downloads/connector/ c/。下载并运行安装程序。之后使用下面的命令:

gem install mysql2 -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Connector C 6.1\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Connector C 6.1\include"'

现在它可以工作了

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:

gem install mysql2 -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Connector C 6.1\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Connector C 6.1\include"'

Now it's working

红颜悴 2024-11-21 04:15:29

我不确定 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.

无尽的现实 2024-11-21 04:15:29

您可以将 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.

舟遥客 2024-11-21 04:15:29

使用 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.

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