Tim Mitchell
Tim Mitchell

Reputation: 653

Can't install mysql2

I'm at my wit's end trying to install mysql2.

I'm running on Ubuntu 12.04 LTS. I installed ruby 1.9.3; rails 3.2.9. Everything goes fine - until I try to install mysql2 - either by including it in the Gemfile and running bundle install, or trying to install it by running gem install mysql2 -v '0.3.11'

The error I get is
'Could not create Make file due to some reason, probably lack of necessary libraries and/or headers.'

Any suggestions would be greatly appreciated.

Upvotes: 0

Views: 222

Answers (3)

Peter de Ridder
Peter de Ridder

Reputation: 2399

To get MySQL support for Rails:

sudo apt-get install libmysql-ruby libmysqlclient-dev

Add the MySQL gem to your gemfile:

gem 'mysql2'

Followed by 'bundle', to let bundler install the gem.

And don't forget to change your config/database.yml, as in:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: [database]
  pool: [n]
  username: [username]
  password: [password]
  host: [host]

Upvotes: 1

sjain
sjain

Reputation: 23344

1) Just add libmysqlclient-dev package using apt-get.

2) Then run the gem install mysql2 command.

Upvotes: 0

benchwarmer
benchwarmer

Reputation: 2774

make sure you have libmysqlclient-dev installed.

sudo apt-get install libmysqlclient-dev

Try installing mysql gem after installing this package

Upvotes: 3

Related Questions