I install the RailsInstaller downloading from this site http://railsinstaller.org/ and also install the mysqlInstaller downloading from this site http://dev.mysql.com/downloads/. Both I have installed in c:\ drive. I have also installed mysql driver from ruby command gem install mysql. Now I haven't Idea how to configure mysql in Ruby on Rails.
I have seen this answer MySQL driver for Rails in Windows 7 x64 they tell to replace libmySQL.dll but where to replace I didn't find such file.
Does anyone have any Idea or solution about my problem?
I had same problem. following solution worked for me
Solution:
the libmysql.dll file is located in the bin directory of your mysql installation.
This file needs to be a copy of it in the Ruby\bin directory.
Related
I upgraded a working Rails app from Mysql 5.7 to 8.0 on my dev machine but it fails to work on a staging/test server setup with the exact same directory structure and env vars.
I'm getting an error "file not found" for /apps/bundle/ruby/2.7.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.so
ldd /apps/bundle/ruby/2.7.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.so shows a file not found (mysql.so.20) (? - I'm not at work so the filenames might be off) that definitely existed and was part of Mysql 5.7.
So the overall question is how to force the mysql2 gem install to relink to the correct new .so files?
There are a lot of moving parts to this, making things a mystery:
installing mysql from a source tarball,
installing in non-standard directories (apps/usr/local/stow/mysql-8.0.16),
using GNU stow to link mysql .so files from the install directory apps/usr/local/stow/mysql-8.0.16 into a common /apps/usr/local/lib directory (the env var LD_LIBRARY_PATH=/apps/usr/local/lib),
vendoring the gems in the bundle on my dev machine using the bundle package --all command so they're part of the git repo.
I've blown away the /apps/bundle directory contents and rerun bundle install thinking that would force a proper linkage of the .so files without success.
Any ideas? TIA!
I am having problems installing mysql2 gem on my windows machine, usually it worked, but now I get Failed to build native extension. I googled around, but there were a lot of linux fixes. I know its not the best thing to work on windows with ruby. Back to the problem, I used gem install mysql2 -- --with-mysql-dir=C:\wamp\bin\mysql\mysql5.6.12\bin --with-mysql-lib=C:\wamp\bin\mysql\mysql5.6.12\lib to install mysql2, it works with mysql, but rails requires mysql2.
Thank you.
mysql2 can be tricky to install. We JUST got a dev box working with Ruby 2.0.0p247, Windows 64bit and mysql 0.3.13. Here are some suggestions:
Make sure you have the latest DevKit installed (http://rubyinstaller.org/downloads/). On the right column of the page, it tells you which version of the DevKit you'll need for your particular version of Ruby. We've found it was easiest to install it to C:\DevKit
Now try and run the gem install mysql2 ... command you listed in your question. Alternatively, for 32bit installs we do:
subst X: "C:\Program Files (x86)\MySQL\MySQL Server 5.6"
gem install mysql2 -v=0.3.13 --platform=ruby -- --with-mysql-include=X:\include --with-mysql-lib=X:\lib
subst X: /d
The subst command creates a virtual drive and helps with the spaces in the path name.
Copy the C:\Program Files (x86)\MySQL\MySQL Server 5.6\lib\libmysql.dll to your Ruby bin directory. You should be off and running if you're working with 32bit.
64bit users however will likely run into another bug once they get mysql2 to build. The above steps will appear to work, but when they actually go to use the mysql2 gem to do something useful, like run rake db:create, they get a segmentation fault. More info and a fix for the issue can be found at https://github.com/brianmario/mysql2/issues/372, https://bugs.ruby-lang.org/issues/8591, https://groups.google.com/forum/#!topic/rubyinstaller/uTNffOt6Yqo
Long story short, a compatible mysql connector c needs to be used instead of the MySQL server directory. A helpful user provided the right connector c and it can be downloaded here (https://www.copy.com/s/CHZ4eT4us6f1/mysql-connector-c-noinstall-6.0.2-winx64.zip). Extract that zip file, and point your gem install mysql2 ... command to the appropriate directories and 64bit happiness will follow. (Don't forget to grab the libmysql.dll from the downloaded connector c folder and place it in your ruby bin directory).
Execute this command in command prompt.
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.1\lib\opt" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.1\include"'
note: change the Mysql installation directory as per your installation.
That should work perfectly
Download the 32-bit Zip Archive of connector from here. Then copy the extracted folder to the root of your C drive for ease of access so that your connector folder path will be something like this
C:\mysql-connector-c-6.1.3-win32\
Now copy this line of code to your cmd and execute (remember to change the connector version number with your one)
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/mysql-connector-c-6.1.3-win32/"'
After trying for a long time I successfully installed mysql2 gem in both of my 32 and 64 bit windows 7 in this way. Cheers!
I cannot seem to run a rail application configured to MySQL. When I run the project, I get the following error:
193: %1 is not a valid Win32 application. - C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so
I've noticed others have hit this but I didn't find any solutions that worked for me. Here's what I've tried so far:
Copying libmysql.dll to the ruby bin folder
Tried older version of MySQL (5.0)
Checked the ImagePath for MySQL on regedit
Can anyone provide guidance here? Is this just a lost cause? Does using Linux or other versions of Ruby/Rails/MySQL combo fix this?
Looks that you installed the binary pre-compiled version of MySQL gem, which requires an specific version of MySQL to be installed.
More important, it requires an specific version of libmysql.dll be available in the PATH so the gem can use it.
I would recommend you uninstall the pre-compiled gem and proceed with the manual compilation steps described here:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
This has been answered before too:
Ruby Gem for mysql 5.5 in windows
Is Datamapper's dm_mysql_adapter gem supported on windows?
Finally installed MySQL for Rails in Windows 64 bit, and now
on windows Mysql native extension prob in ruby on rails gem time
Hope that helps.
I just downloaded zipped-up version of mysql 5.5.9 (mysql-5.5.9.zip, which I put in c:\progream files), unzipped it, and got this dir (screenshot):
http://mayacove.com/misc/ss_mysql.gif
I hadn't installed mysql server on windows in a few years.. I remember that years ago you used to get an installer called setup.exe, when you ran that it ran instal/config wizard, that would walk you thru installation and setup.. so how do I run that wizard now???
no file with ext .exe inside this dir (no file with ext .msi either) no serious instructions here
http://dev.mysql.com/doc/refman/5.5/en/windows-installation-layout.html
would appreciate some help.. thank you very much...
There is a package available with a MSI installer.
Just follow the instructions on http://dev.mysql.com/downloads/mysql/
You should use msi installer. It's on download page first or second option.
I have a new rails application which I have created under Windows 7 by going into a directory and typing "rails newapp". The creation went fine, and when I access the root page, all is well. However, when I try to access a page that would access the database, I get this:
193: %1 is not a valid Win32 application.
In the developer.log. Mysql is running fine on my machine, and I have other applications which I have running in here in other directories, it's just this one that doesn't work. Any thoughts?
Here's the answer that worked for me. Turns out it was an issue of x64 vs. x32 issue and Rails 2.3.2.
The answer I got from here (http://osdir.com/ml/RubyonRailsTalk/2009-06/msg01775.html):
In case anyone else has the same
problem after a lot of struggling on
my Windows XP x64 machine, with MySQL
5.1.30 (x64) and Rails 2.3.2 installed, this above suggestiong
helped me.
Download libMySql.dll from here (http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/)
and putting it in ruby\bin solved the
problem.
Solved by following the directions on this blog here: http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
which involves using the non installer version of the MySQL Connector http://dev.mysql.com/downloads/connector/c/
I could not get webrick to run on x64 Windows 7 system -- got the same error
"193: %1 is not a valid Win32 application”
If I just replaced the file libmysql.dll (as suggested in posts above), I got a different error.
"Incorrect MySQL client library version!"
My Path set like this: C:\Ruby187\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Ruby187\lib\ruby\gems\1.8\gems\rails-3.1.1\bin
(didn't need to change the path again)
This error occurs if you have a file with name "Program" in the root of your drive. Say for example you are trying to execute "C:\Program Files\SomeApp\Bin\SomeExe.Exe" it tries to execute "C:\Program" if it exists. In some situations a file with this name get created if you forget to quote "C:\Program Files..." with some commandline commands. This of course also applies for you D: drive, etc.
This error often occurs if you try to start services, but may occur in other situations.
Simply deleting the file C:\Program or D:\Program etc. solves the problem.
Having run into multiple issues setting up MySQL with Rails on Windows x64 my recommendations are:
Install the 32-bit version of MySQL, do not try to use the 64-bit version.
Install into a path with no spaces, do not accept a default like "C:\Program Files\MySQL\MySQL Server 5.5\"
Install the MySQL gem with an invocation similar to:
gem install mysql -- --platform=ruby --with-mysql-dir="D:\Programs\MySQL\MySQL-Server-5.5" --with-libmysqllib="D:\Programs\MySQL\MySQL-Server-5.5\lib\"
Be sure to uninstall/reinstall the gem whenever you install a new version of MySQL.
Make sure D:\Programs\MySQL\MySQL-Server-5.5\lib is included in your path, as well as D:\Programs\MySQL\MySQL-Server-5.5\bin. Make sure other copies of libmysql.dll are not being picked up from elsewhere on your path or your ruby installation directories.
This worked for me with mysql-5.5.15-win32, mysql-2.8.1-x86-mingw32 and Windows 7 x64.
Copy the file libmysql.dll from your MySQL installation directory and paste it into your Ruby installation's bin directory. You may need to download a zip archive from http://dev.mysql.com/downloads/mysql/ if your MySQL installation directory doesn't already include the file libmysql.dll.
Using Ruby (1.8.7) with MySQL(5.5) on Windows 7 and also getting error 193.
Copying the libmySQL.dll to ruby /bin worked fine for me.
C:\Work\redmine-2.4.1\config\database.yml content:
# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
production:
adapter: mysql
database: redmine
host: localhost
username: root
password: "pwd#123"
encoding: utf8