MySQL
Install the package:
# apt-get install mysql2
Try to install the gem
$ gem install mysql2
If you're planning on using the mysql2 gem for your application then you'll want to install the libmysqlclient-dev package before you do that. Without it, you'll get an error when the gem tries to compile its native extensions:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/home/ryan/.rubies/ruby-2.2.0/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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.
Install this package using:
$ sudo apt-get install libmysqlclient-dev
If you are running mysql and rake complains about not being able to find your mysql.sock file, you will need to add "socket: " to each of the database definitions
Example database.yml for Development
development:
adapter: mysql
socket: /var/mysql/mysql.sock
database: wagn_development
username: wagn
password: hi_im_a_password_right_up_in_here
host: localhost
test:
adapter: mysql
socket: /var/mysql/mysql.sock
database: wagn_test
username: wagn
password: woo_hoo_password
host: localhost
production:
adapter: mysql
socket: /var/mysql/mysql.sock
database: wagn_production
username: wagn
password: password_ahoy
host: localhost