缺少MySQL客户端

时间:2015-10-25 23:21:35

标签: mysql ruby-on-rails ruby git-bash

所以我跟着这个教程:

https://www.youtube.com/watch?v=MX6wYbsUO-Y

它使用git.bash来安装mysql2 gem,并且我坚持了最后一步。他使用的过程对我来说不起作用,所以我只需输入:

gem install mysql2 -s http://rubygems.org

在此之后,它开始工作,但后来它说缺少mysql客户端:

    gem install mysql2-0.3.7.gem --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib
        ERROR: Failed to build gem native extension.

    c:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes

checking for rb_thread_call_without_gvl() in ruby/thread.h... yes

checking for rb_thread_blocking_region()... yes

checking for rb_wait_for_single_fd()... yes

checking for rb_hash_dup()... yes

checking for rb_intern3()... yes

checking for mysql_query() in -lmysqlclient... no
-----
mysql client is missing. Check your installation of MySQL or Connector/C, and try again.
-----
*** 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.

我是使用mysql的新手,我甚至不知道从哪里开始,如果有的话,任何人都可以简单地将我引导到我自己能够解决的资源吗?

2 个答案:

答案 0 :(得分:0)

首先需要download and install MySQL

如果在安装后仍然无法找到它,请在gem install上提供路径。

答案 1 :(得分:0)

首先,请在询问特定平台相关问题时提供版本号

这是一个2岁的问题,但在Windows上启动ruby时问题仍然存在

以下是解决问题所需的一些步骤(截至2017年8月)

  1. 请安装Devkit和MSYS(现在附带ruby安装程序)
  2. 安装mysql2 gem时检查rubygem repo提供的版本是否实际上适用于您的体系结构和ruby版本,例如: mysql2 0.4.9没有为windows for ruby​​ 2.4
  3. 提供编译版本
  4. 如果没有提供,那么你需要编译它

    3.A。首先从这里下载Mysql c连接器,zip版本更好 https://dev.mysql.com/downloads/connector/c/ 重要的是请记住您的操作系统架构,例如,如果您想在64位计算机上运行它,必须下载64位

    3.B。第二次将其解压缩并运行此命令 gem install mysql2 --platform=ruby -- '--with-mysql-lib="[your_full_path_to_extracted_mysql_connector]\lib" --with-mysql-include="[your_full_path_to_extracted_mysql_connector]\include"' 请注意'最后是否重要

  5. 应该说安装了1个宝石

  6. 使用此命令检查您的连接 项目根目录下的rails db:schema:dump。你会看到一个 名为schema.rb的db文件夹中的新文件表示它正在运行。

  7. 您会看到控制台中显示的具体问题,如果在谷歌搜索它,您将找到答案。
  8. 祝你好运:)