Reputation: 5299
I started my rails project, when I went to rails console, I suffered below error,
$ rails c
Could not find gem 'mysql2 (>= 0.3.18, < 0.5)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
And I tried bundle install
the result is below.
An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.10' --source 'https://rubygems.org/'` succeeds before
bundling.
In Gemfile:
mysql2
How can I fix such error? I doubted version conflict.if someone has already experienced such issue.please let me know Thanks.
Upvotes: 2
Views: 1755
Reputation: 1504
You can install MySQL server and client from the packages in the Ubuntu repository. As part of the installation process, you'll set the password for the root user. This information will go into your Rails app's database.yml
file in the future.
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
Installing the libmysqlclient-dev gives you the necessary files to compile the mysql2
gem which is what Rails will use to connect to MySQL when you setup your Rails app.
Upvotes: 4
Reputation: 175
inside of your gemfile, you need
gem 'mysql2'
then try bundle install
after adding that
Upvotes: 2
Reputation: 92
you must have mysql-server installed on you machine,
Install MySQL on you machine from this link MySQL Installation Guide
then bundle install after adding gem 'mysql2' to you Gemfile.
Upvotes: 1