Monday, September 12, 2011

Ruby On Rails mysql2 error

I was having trouble installing mysql2 gem on my Win7 64 bit. I have copied these instructions from stackoverflow. And these really work.

For Win 7:

  1. Download a zip file with mysql server 5.1 NOT the msi one. Make sure it's 32-bit NOT 64-bit. (From here
  2. Since there is no installer file with this, create a folder c:\mysql-gem-install - you can remove it once you finish.
  3. Extract all the files from the zip file into the folder you just created.
  4. now run this command
    gem install mysql2 -- '--with-mysql-lib="c:\mysql-gem-install\lib\opt" --with-mysql-include="c:\mysql-gem-install\include"'
I just installed mysql2 gem v. 0.3.7
EDIT: One more thing: make sure you run the command in Command Prompt directly. As in not PowerShell or Consol2 - for some reason if you try that it will give you and error " invalid option" - has to do with the way -- is parsed.
--Answered by Nick Gorbikoff

For Linux:

sudo apt-get install libmysql-ruby libmysqlclient-dev

--Answered by spacemonkey

I successfully installed mysql 5.5, and gem mysql2-0.3.7

1 comment: