30
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Amazon Linuxにmysql2を入れようとしたらエラーがでる

Last updated at Posted at 2014-10-28

急いでいる人のために、先に解決方法を書いておくと
$ sudo yum install mysql-devel
をしてから
$ gem install mysql2
をすれば良い。


EC2でAmazon Linuxを借りて、
gem install mysql2
をしたら、以下の様に怒られたので対処法を書いておく。

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    /home/ec2-user/.rbenv/versions/2.1.2/bin/ruby 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
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql 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.

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=/home/ec2-user/.rbenv/versions/2.1.2/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-mysql-config
	--without-mysql-config

extconf failed, exit code 1

Gem files will remain installed in /home/ec2-user/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16 for inspection.
Results logged to /home/ec2-user/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.16/gem_make.out

原因はmysql.h がないことらしいので、
$ sudo yum install mysql-devel
とすれば良かった。

その後に、もう一度
$ gem install mysql2
をすれば成功する。

30
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?