首页 > 数据库 >windows搭建rails环境中,mysql2 gem 安装error问题

windows搭建rails环境中,mysql2 gem 安装error问题

时间:2024-03-08 16:00:41浏览次数:28  
标签:mysql2 windows MySQL rails -- version mysql gem

windows搭建rails环境中,mysql2 gem 安装error问题

可以尝试使用下面几种方法:

1. Uninstalling and reinstalling the gem will often solve this issue with no need to download and move files around by hand. From your rails app directory:

> gem uninstall mysql2

You have requested to uninstall the gem:
    mysql2-0.3.11
database_cleaner-0.9.1 depends on [mysql2 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled mysql2-0.3.11

> bundle install

Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Using rake (0.9.2)
Using i18n (0.6.1)
... <SNIP> ...
Installing mysql2 (0.3.11) with native extensions
... <SNIP> ...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

2. 

I had the same problem as you, or at least the symptom was the same.

Background: I was using Rails 3, the mysql2 gem, and MySQL community server version 5.5.21 (32-bit) installed locally on my Windows machine. I grabbed the client library (libmysql.dll) from the MySQL installation and copied it to my ruby installation's bin folder.

When I ran bundle exec rake db:create, I got the same error message as you and I thought "Hey, how can the client library be outdated when I got it from the latest MySQL release?"

There's a helpful message that is shown when you gem install mysql2. Unfortunately, if you install the gem with Bundler, Bundler eats the message. Here it is:

=========================================================================
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

 

3. 

If you are using 64bit version of mysql and 32bit version of ruby, then check this solution on http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

You basically have to download a single connector from mysql website, and compile mysql or mysql2 with connector you downloaded.

for Ruby 1.9.2:

gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

for Ruby 1.9.3: (showing mysql2 variant)

gem pristine mysql2 -- --with-mysql-config=C:\mysql-connector-c-noinstall-6.0.2-win32   

Note the use of forward slashes for the directory where MySQL Connector/C was extracted.

 

标签:mysql2,windows,MySQL,rails,--,version,mysql,gem
From: https://www.cnblogs.com/hello-ruby/p/18061170

相关文章

  • Rails中的includes和joins的区别与用法
    includes和joins的不同当includes和joins的时候最重要的概念就是他们有他们的典型用例。includes使用贪婪加载(eagerloading)而joins使用懒加载(lazyloading),两者都非常有用,但是也都很容易被滥用导致程序性能降低或过度使用。如果我们看一眼rubyonrails文档,描述includes最重......
  • windows 安装 minio
    1.打开官网链接https://www.minio.org.cn/2.点击下载3.点击windows,然后点击MINIOSERVER右侧的DOWNLOAD进行下载4.找到环境变量,新建系统变量,设置MINIO的用户名和密码5.启动MINIOSERVERminio.exeserverD:/data#server后面的路径需绝对路径6.可以......
  • 关于rails打印pdf prawn gem的使用
    1.安装gem  gem'prawn'gem'prawn-table' 2.由于prawn包中不支持打印中文,所以需要将windows电脑路径下的字体复制到gem的安装路径下windows字体路径:C:\Windows\Fontsgem中安装路径:/Users/zhoukong/.rvm/gems/jruby-9.0.0.0.pre1@rails4/gems/prawn-2.2.2/data/fonts......
  • 添加windows terminal到windows10右键菜单中
    前置条件,windows10中不自带windowsterminal,可以通过microsoftstore下载,然后不会像windows11那样在鼠标右键菜单中生成一个“在终端中打开”,需要通过注册表新建一个右键菜单项来完成。新建一个注册表脚本,此处示例wt.reg,代码示例如下:WindowsRegistryEditorVersion5.00......
  • nginx windows重启
    请注意,你需要以管理员权限运行命令提示符窗口才能执行这些命令。在Windows上重启Nginx服务,可以通过以下步骤实现:打开命令提示符窗口(按下Win+R键,输入cmd并回车)。进入Nginx安装目录的bin文件夹中。例如,如果Nginx安装在C:ginx目录下,则输入cdC:ginx\bin并回车。执行Nginx的重......
  • windows下快速生成项目目录树(转)
    原文:https://blog.csdn.net/air_knight/article/details/109039230TreeforWindows下载:https://gnuwin32.sourceforge.net/packages/tree.htm1、、背景每当逛github看到其他作者的项目都使用完整的目录树,就会想在自己做项目的时候生成目录树,方便了解整个项目的体系结构。2、......
  • FFU、WIM、ESD、VHD和VHDX都是与Windows操作系统部署、备份和虚拟化相关的文件格式。
    FFU(FullFlashUpdate)文件格式是微软开发的,用于在Windows设备上进行固件更新和完整系统部署的一种映像文件格式。FFU文件包含了设备的完整磁盘映像,包括所有分区、文件系统和数据。这种格式允许精确复制存储设备的内容,提供了一种高效且可靠的方式来恢复、更新或部署设备。下面是对F......
  • zabbix监控windows DHCP server
    一、准备在HDCP服务器上创建两个脚本,check_dhcpscop.ps1和 check_dhcpscop_value.ps1 》1、创建powershell"check_dhcpscop.ps1"#获取DHCP作用域,输出结果要为json格式,key值格式必须为{#NAME},必须大写$scops=Get-DhcpServerv4Scope|select@{name="{#SCOPNAME}";expressi......
  • Windows虚拟机安装Linux的基础配置
    Linux实用本次练习实用的是Ubuntu20.04基础配置root用户进入root用户模式sudosu解决网络参考文章一篇搞定Ubuntu22.04下联网问题、ifconfig、net-tools不能用的问题(亲测可行_仅供参考)_无法定位软件包net-tools-CSDN博客编辑->虚拟网络编辑器:删除原先是VMnet*,重新“添......
  • 【VMware ESXi】如何在独立的ESXi主机上配置vTPM并安装Windows 11操作系统。
    根据微软发布的Windows11操作系统要求,这个版本的系统需要硬件支持受信任的平台模块(TPM)才能进行安装和使用,不然就会提示你“这台电脑无法运行Windows11。这台电脑不符合安装此版本的Windows所需的最低系统要求。有关详细信息,请访问https://aka.ms/WindowsSysReq”错误。关于受......