人力検索はてな
モバイル版を表示しています。PC版はこちら
i-mobile

Ruby on Rails 3 での mysql 関連エラー
scaffold や rake db:create 時に以下のようなエラーが出ます。
mysql.h is missing. please check your installation of mysql and try again.

■バージョン
-----------------------------------------
$ rpm -qa | grep centos-release
centos-release-notes-5.7-0
centos-release-5-7.el5.centos

$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]

$ gem -v
1.3.7

$ rails -v
Rails 3.0.9
-----------------------------------------

bundle installでエラー
-----------------------------------------
$ rails new demo -d mysql
$ cd demo
$ bundle install
Fetching source index for http://rubygems.org/
Could not find gem 'mysql-ruby (>= 0) ruby' in any of the gem sources listed in your Gemfile.
-----------------------------------------

以下のようにしてbundle installは成功するようになりましたが、
-----------------------------------------
$ vi Gemfile
gem 'ruby-mysql'

$ vi config/database.yml
production:
host: 127.0.0.1 追記

または

$ sudo gem install ruby-mysql
Successfully installed ruby-mysql-2.9.4
1 gem installed
(略)

$ vi Gemfile
gem 'ruby-mysql'
-----------------------------------------

今度はscaffoldでエラーとなります。
対処方法をお願いします。

●質問者: ikazuo
●カテゴリ:インターネット ウェブ制作
○ 状態 :終了
└ 回答数 : 2/2件

▽最新の回答へ

1 ● techmedia-think
●50ポイント

最初のエラーではmysql.hがみつかってないようですが、mysql.hが存在していないということはないでしょうか。存在していない場合は、yum install mysql-develなどでインストールできるかと思います。

また、Rails3からはmysqlのgemがruby-mysqlからmysql2に変更になったかと思うので、それが原因かもしれません。
以下のサイトが参考になるかと思います。
http://d.hatena.ne.jp/deadlight/20100906


ikazuoさんのコメント
mysqlのincludeファイルが見つからずエラーとなりました。 >|| $ rails new hoge -d mysql 正常終了 $ sudo gem install mysql2 予想通りのエラー $ sudo gem install mysql2 -- --with-mysql-include=/usr/include/mysql Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /usr/local/bin/ruby extconf.rb --with-mysql-include=/usr/include/mysql checking for rb_thread_blocking_region()... yes checking for rb_wait_for_single_fd()... no 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=/usr/local/bin/ruby --with-mysql-config --without-mysql-config Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10 for inspection. Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/ext/mysql2/gem_make.out ||< 回答ありがとうございます。

ikazuoさんのコメント
mysql-devel がインストールされていない可能性があります。 $ sudo yum install mysql-devel でエラーとなっているのでしょうか? >|| $ sudo yum list installed | grep mysql mysql.x86_64 5.5.17-1.el5.remi installed mysql-libs.x86_64 5.5.17-1.el5.remi installed mysql-server.x86_64 5.5.17-1.el5.remi installed mysqlclient15.x86_64 5.0.67-1.el5.remi installed php-mysql.x86_64 5.3.8-5.el5.remi.1 installed $ sudo yum install mysql-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.nara.wide.ad.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mysql-devel.i386 0:5.0.77-4.el5_6.6 set to be updated --> Processing Dependency: mysql = 5.0.77-4.el5_6.6 for package: mysql-devel --> Processing Dependency: libmysqlclient.so.15 for package: mysql-devel --> Processing Dependency: libmysqlclient_r.so.15 for package: mysql-devel ---> Package mysql-devel.x86_64 0:5.0.77-4.el5_6.6 set to be updated --> Running transaction check ---> Package mysql.i386 0:5.0.77-4.el5_6.6 set to be updated --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================== Package Arch Version Repository Size =================================================================================================================== Installing: mysql-devel i386 5.0.77-4.el5_6.6 base 2.4 M mysql-devel x86_64 5.0.77-4.el5_6.6 base 2.5 M Installing for dependencies: mysql i386 5.0.77-4.el5_6.6 base 4.8 M Transaction Summary =================================================================================================================== Install 3 Package(s) Upgrade 0 Package(s) Total size: 9.7 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Check Error: package mysql-5.5.17-1.el5.remi.x86_64 (which is newer than mysql-5.0.77-4.el5_6.6.i386) is already installed file /etc/my.cnf from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/charsets/Index.xml from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/charsets/cp1250.xml from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/charsets/cp1251.xml from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/czech/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/danish/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/dutch/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/english/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/estonian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/french/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/german/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/greek/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/italian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/japanese/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/korean/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/polish/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/romanian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/russian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/serbian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/slovak/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/spanish/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/swedish/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-libs-5.5.17-1.el5.remi.x86_64 file /usr/bin/mysql_find_rows from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/bin/mysqlaccess from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/my_print_defaults.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysql.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysql_config.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysql_find_rows.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysql_waitpid.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysqlaccess.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysqladmin.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysqldump.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 file /usr/share/man/man1/mysqlshow.1.gz from install of mysql-5.0.77-4.el5_6.6.i386 conflicts with file from package mysql-5.5.17-1.el5.remi.x86_64 Error Summary ------------- $ ||<

techmedia-thinkさんのコメント
ちなみにmysql.hは/usr/include/mysql直下に存在しているのでしょうか?

ikazuoさんのコメント
ご指摘のとおり、やはりmysql-develの問題のようです。 mysqlのバージョンをmysql-develも含め、5.0系で揃えるように変更したいと思います。 明日実施の予定です。

2 ● kodairabase
●50ポイント

mysql.hが見つからないというエラーです。

関連質問

●質問をもっと探す●



0.人力検索はてなトップ
8.このページを友達に紹介
9.このページの先頭へ
対応機種一覧
お問い合わせ
ヘルプ/お知らせ
ログイン
無料ユーザー登録
はてなトップ