We are going to use mysql 5.5 in our application for production. I did some online search and it seems that mysql2 0.2.6 is the one for mysql5.5. Is this gem good for windows as well? Any tips on how to install and manage for production?
Thanks.
The gems (either mysql or mysql2) provides an version-independent layer to the version of MySQL you are running.
However, if you're using a pre-compiled gem, it will require a version specific MySQL library be installed in your system.
To avoid that, you can use MySQL Connector/C which provides a version-independent way to connect to MySQL.
I've documented how to compile mysql gem against MySQL Connector/C in this blog post:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
mysql2 gem has some issues on Windows so I would recommend you use mysql gem for the time being.
Hope this helps.
Related
I want to use a remote MySQL database. Is there any way to install mysql2 gem in OS X without installing MySQL server locally?
Update: I found the solution. Actually, I don't need the MySQL server installed locally, I just need to install the adapter as follow..
brew install mysql-connector-c
Followed by,
gem install mysql2
Looks like the gem needs mysql installed locally to run as it uses some underlying c libraries for the client. I don't think it can work without it.
Check out https://github.com/tmtm/ruby-mysql which i believe is native ruby and may not need it, but is not compatible with 4.1.x.
I am trying to start a new application Ruby on Rails 3.1 on Debian Squeeze with MySQL Server 5.1 (the latest supported by Debian stable version).
I have problem with the mysql2 gem. When I use mysql2 gem version 0.2.6 rake migrations fail with error undefined method rows for nil class. I gooogled and everybody says that this error is resolved when one upgrades mysql2 gem to 0.3.X. However, when I do this upgrade I get another error about gem having been compiled for 5.5 mysql client and not 5.1.
Any help would much appreciated. Maybe the answer is "NO. YOU CANNOT DO IT". Even then, I want to know that.
Thanks in advance
Panayotis
Well, this is a tricky question. My current rails package latest version is 2.3.5-1.2+squeeze2 and the current mysql-server package is 5.1.49-3, both from the stable debian repositories.
However, you're trying to install RoR 3.1. That means you're not on stable or you are not trying to install it from any of the official debian repository at all (it is not wheeze nor sid).
If you can install the stable version of rails, go ahead and I bet you won't have any trouble. Otherwise, if you want the most current release I'm pretty sure you'll have to go for the dirty way. It might probably involve download a 5.5 MySQL (not from the repositories, because it isn't there) and messing with the libraries.
Remember if you require newer packages (such as newer libraries) and you don't want to use the testing repositories, you can always give debian backports a try.
i want to develop rails 3 apps using mysql on windows 7 (64 bit) and i have installed mysql via the msi download from the mysql site.
my question is that do i still need to install the mysql gem?
thanks
The mysql gem provides the ruby bindings, so yes, you need to install this.
With Rails 3 you should use the mysql2 gem rather than the mysql gem.
Here is a proper solution for anyone interested, that doesn't mess up your current installation of mysql server
Download a zip file with mysql server 5.1 NOT the msi one. Make sure it's 32-bit NOT 64-bit. (From here)
Since there is no installer file with this, create a folder c:\mysql-gem-install - you can remove it once you finish.
Extract all the files from the zip file into the folder you just created.
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
Yes you do. The mysql gem is a ruby driver (interface) to connect to the mysql database.
You should use mysql2 gem instead with Rails3.
I'm trying to install the mysql2 gem for a rails app on a machine with an external mysql server. The machine I'm installing onto doesn't have or need a mysql server on it. However, whenever I try to install it always checks for a mysql install and fails.
Is there an install configuration or work-around for this?
Cheers
You need just the MySQL header files to be there where the native compiling takes place.
Depending on your OS / Distribution you should find the way to install the header files without installing the actual server (Debian / Ubuntu alikes should allow you to do so with the standard apt-get, but I might be wrong).
If you are on Windows, please check this post about mysql2 gem issues on Windows.
When trying to install the mysql gem from cPanel on my website, I get an error saying that the gem requires Ruby >= 1.8.6.
This is a shared server and the version of Ruby is 1.8.5 and can't be upgraded.
I do not have shell access and it seems the only way for me to install a gem is through the list of gems within cPanel.
How can I get mysql for my website?
You can try to install an older gem. 2.7.5 seems to be the proper version.
Ruby 1.8.5 is pretty old and as far as I know hasn't been actively supported by Rails for a while. You really need 1.8.6 and preferably 1.8.7. If your host won't upgrade it may be time to look elsewhere. If you really have no other option, you should to what Yuval suggests and try installing an older version of the gem.
No one having answered how to install a gem without shell access, I'll assume it can't be done and so will accept my own answer.