0

所以我有一个大问题我想开始使用 rails 2.3.11 和 ruby​​ 1.8.7 firs 我安装了我的 sql

    gem install mysql

然后我跑

    rake db:create

但我有一个错误

    Couldn't create database for {"adapter"=>"mysql", "database"=>"test_development", "encoding"=>"utf8", "reconnect"=>false, "username"=>"root", "pool"=>5, "host"=>"localhost", "password"=>nil}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

经过一番搜索,我找到了一个解决方案来运行这些命令,我​​卸载 mysql 并运行这些行

    gem install mysql -- --with-mysql-dir=/usr/local \ --with-mysql-config=/usr/local/bin/mysql_config

但我遇到了另一个错误

    ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

    /home/asnad/.rvm/rubies/ruby-1.8.7-p370/bin/ruby extconf.rb --with-mysql-dir=/usr/local  --with-mysql-config=/usr/local/bin/mysql_config
    extconf.rb:5: command not found: /usr/local/bin/mysql_config --cflags

    *** 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/asnad/.rvm/rubies/ruby-1.8.7-p370/bin/ruby
--with-mysql-config

我正在尝试过去两天,请在我刹车笔记本电脑之前帮助我提前谢谢。

4

2 回答 2

0

尝试使用mysql2 gem.
如果您打算为您的应用程序使用 mysql2 gem,那么您需要libmysqlclient-dev在执行此操作之前安装该软件包。更多详情: http ://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

于 2013-01-13T12:11:16.233 回答
0

我已经解决了这个问题

gem uninstall mysql
export PATH=$PATH:/usr/local/mysql/bin
sudo gem install mysql
于 2013-01-17T10:25:19.883 回答