I'm trying to figure my way around the vastly complex maze that is rails configuration. So far, I'm managed to set up rvm on ubuntu (for some reason, ruby is outdated in the ubuntu repo's). I've managed to set up a rails project. I want my test project to use mysql rather then mysqlite.
When I tried 'rake db:migrate', I got an error: "!!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'"
When I try 'gem install mysql', I get an error, telling me that I need to provide parameters to the installation command. However, the list of parameters is huge, and I have no idea which ones to select.
How can I get rails3 via rvm running on ubuntu with mysql ?
Thanks.
I had the same problem, all you need to do is to install the libmysqlclient-dev first.
cheers
First, you need mysql installed. You can install it using Ubuntu's package manager. No special steps needed. You also need to initially create your database and user using the mysql tool. This link shows how to do that:
http://www.tutorialspoint.com/ruby-on-rails/rails-database-setup.htm
Second, you need to have the mysql2 gem listed in your Gemfile. This tells Rails to go ahead and use that gem. You need a line like this:
gem 'mysql2', '< 0.3'
I'm specifying the version to be less than 0.3 because I'm using Rails 3.0.7 and version 0.3 and higher are for Rails 3.1. Also, be sure to use the mysql2 gem and not mysql - it seems to handle character encoding better.
Third, run "bundle install" so Rails downloads and installs the mysql2 gem.
Lastly, you need to change your database.yml file to put in the connection information for your database like so:
development:
adapter: mysql2
database: your_database_name
username: your_username
password: your_password
encoding: utf8
The encoding part is just what I'm using, you may need something different. This entry tells Rails how to find your database in the development environment.
Once that's all in place, things should work.
sudo apt-get install libmysql-ruby libmysqlclient-dev
If the above command does not work because libmysql-ruby
cannot be found, the following should be sufficient:
sudo apt-get install libmysqlclient-dev
On Red Hat/CentOS and other distributions using yum:
sudo yum install mysql-devel
On Mac OS X with Homebrew:
brew install mysql
then run
bundle install
to install to gems as listed in gemfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With