How to install mysql2 gem on ubuntu when i use rails3 via rvm?

I'm trying to figure my way around a very complex maze, which is a rail configuration. So far, I have managed to configure rvm on ubuntu (for some reason, Ruby is deprecated in ubuntu repositories). I managed to create a rails project. I want my test project to use mysql, not mysqlite.

When I tried "rake db: migrate", I got an error: "!!! There is no gem mysql2. Add it to your Gemfile: gem 'mysql2'"

When I try to install gem install mysql, I get an error message telling me that I need to provide parameters to the install command. However, the list of options is huge, and I have no idea which ones to choose.

How can I get rails3 via rvm running on ubuntu with mysql?

Thank.

+5
source share
5 answers

I had the same problem, all you have to do is install libmysqlclient-dev first.

amuses

+22
source

First you need to install mysql. It can be installed using the Ubuntu package manager. No special steps required. You also need to first create your database and user using the mysql tool. This link shows how to do this:

http://www.tutorialspoint.com/ruby-on-rails/rails-database-setup.htm

-, , Gemfile mysql2. Rails . , :

gem 'mysql2', '< 0.3'

, 0,3, Rails 3.0.7, 0.3 Rails 3.1. , gem mysql2, mysql - .

-, "bundle install", Rails mysql2.

, database.yml, :

development:
  adapter:  mysql2
  database: your_database_name
  username: your_username
  password: your_password
  encoding: utf8

- , , - . Rails, .

, .

+2
sudo apt-get install libmysql-ruby libmysqlclient-dev

, libmysql-ruby , :

sudo apt-get install libmysqlclient-dev

Red Hat/CentOS yum:

sudo yum install mysql-devel

Mac OS X Homebrew:

brew install mysql

bundle install

, gemfile

+1

, gem Gemfile, :

- :

source 'http://rubygems.org'

gem 'rails', version
gem 'mysql', version

- gem, , .

Then go to the project directory and run the bundle command and you should be installed.

0
source

All Articles