0

I am on Windows 7 and trying to use MySQL with Rails 3, I am beginner and just reading Rails tutorials, there is this configuration given:

development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock

I have MySQL installed in Xampp, so where can I mention that it can access MySQL with localhost, what changes will be required, so that I can use that MySQL with Rails 3 app?

halfer
  • 19,824
  • 17
  • 99
  • 186
Hafiz
  • 4,187
  • 12
  • 58
  • 111

1 Answers1

2

mysql2 gem installation is similar to mysql gem installation. Please see the following blog post which contains installation instructions for mysql gem:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

You can ignore the MySQL installation instructions. You will need MySQL Connector/C download and then copy libmysql.dll from it to your Ruby installation (RailsInstaller one).

Hope that helps.

Luis Lavena
  • 10,348
  • 1
  • 37
  • 39
  • so what will be the difference in configurations of rails for db? I currently have are as defined above. – Hafiz Oct 17 '11 at 21:40
  • if you mean `config/database.yml` both are the same (database, host, port, username, etc) except for `adapter` field. If you mean something else, please explain. – Luis Lavena Oct 19 '11 at 08:39
  • what will be path for socket, while I am using XAMPP in windows, my mysql directory is d:\xampp\mysql\ – Hafiz Oct 20 '11 at 11:36
  • 1
    On Windows there are no sockets for MySQL, so remove that line, you need host, port, database, username, password and perhaps enconding if you're not using UTF8 – Luis Lavena Oct 20 '11 at 11:56
  • and will my adapter mysql2 or simply mysql as I am using mysql of xampp? when I run rake db:create, it says rake aborted! and "uninitialized constant Mysql2" – Hafiz Oct 21 '11 at 22:44
  • You need to modify config/database.yml to use the right adapter and install the proper gem. I can't help you with that. – Luis Lavena Oct 24 '11 at 09:13