Rails MySql 5.0 on Windows setup problem/fix libmysql.dll

By hillemania

So this morning I was trying to connect to a mysql database in a rails app. I’ve actually been dealing with Rails for quite a while now without needing a database, so it had been awhile since I had last connected. So I setup a database, edit my database.yml file and BLAM!, it breaks and I get some call about a libmysql.dll that is missing. I assumed that this must be becuase I don’t have the correct rails or mysql gems installed, so I tried updating those, then tried removing everything and reinstalling, still the same problem.

Finally I found the solution, the libmysql.dll file is located in the bin directory of your mysql installation. There also needs to be a copy of it in the Ruby\bin directory. I’m not sure what is supposed to magically copy that over, but following the steps on all the install HowTo’s there was never any mention of it. So after copying the file over everything is working fine and dandy. So just in case you get in this pickle, here is your solution.

28 Responses to “Rails MySql 5.0 on Windows setup problem/fix libmysql.dll”

  1. Andrew Says:

    You shouldn’t have to copy the file over. Just add “C:\mysql\bin” (or wherever your mysql/bin dir is located) to your Windows system path (environment variables) and reboot your system.

  2. Jeff Says:

    I actually had the mysql\bin in my system path and it wasn’t working until I copied it over. Another guy I know had the same issue and moving the file worked for him.

  3. Yamaniac Says:

    You rock man! It worked…

  4. hillemania Says:

    very glad that it helped, I was so frustrated when I got stuck on it

  5. MauricXe Says:

    OMG THAT HELPED TY!

  6. colabus Says:

    thanks bud, spent the last half hour looking for the reason that was playing up.

  7. Ben Says:

    Thank you.

    I had this same problem. Placing the file in Windows\System32 didn’t work. I can’t explain why, but putting the file right in ruby\bin works great.

  8. Naru Says:

    That did the trick. I had the path correct in my environment path variable and still it could not see it. Copying the file libmysql.dll from mysql/bin to ruby/bin directory did the trick.

    Thanks

  9. James Says:

    Thanks a bunch, you saved me a couple hours. That’s a lot of dev time. Thanks!

  10. Tal Says:

    Hi,
    I’m trying to understand where to locate the ruby/bin directory.
    I tried to locate it under: C:\Program Files\MySQL\MySQL Server 5.0
    but it didn’t help.

    can you help?

    Thanks!

  11. hillemania Says:

    the ruby/bin directory is located wherever you installed Ruby at on your machine, the default is c:/ruby

  12. Bruno Says:

    I’m using windows vista and ruby 1.8.6 and I didn’t need to copy the file. It worked puting the path as an enviromment variable.
    Thanks!

  13. Janus Says:

    I solved mine by adding libmysql.dll to system32, however, I noticed that my database is no more predictable. When I run some like rake install at the console, it runs rake db:migrate inside the rakefile which creates tables(this is printed on the development log), however , when I check my database , I would not find any tables.

  14. Luke Says:

    It did work! Thank you very much!

  15. Gary (aka fool4jesus) Says:

    UR da man! Thanks very much!

  16. demogar Says:

    thank you ver much dude!!

  17. RC Says:

    Thanks!!

  18. Most Glorious <h1>HelloWorld</h1> « derekbrenner.com Says:

    [...] cant find libmySQL.dll when I test in the browser.  So heres the tricky part.  I finally found on hillemania blog that you have to manually copy the libmySQL.dll file [...]

  19. NeoOrion Says:

    Thanks for your post. I have the same problem, but with your information I have can save this error. Thanks again :)

  20. Blogger Says:

    Thanks for your help! It works. Saves me a lot of time! bless you

  21. Jorge Cea Says:

    Thanks for your suggestion I spent countless hours finding a solution for this problem, it finally worked after I copied that file to the ruby\bin directory…Thanks a lot!!!!

  22. genlinux Says:

    podaa paradesi

  23. Ilya Says:

    Had and still have the same problem with Ruby on Windows. I had copied to system32 and whatever – working unstable. I tried lots of cases even without %path% variables and I noticed (with using filemon.exe) that Ruby works with mysql.so (v.2.7.3) library and it works awfully unstable: samotime it appeared to work and enother one not. I this main problem is mysql.so.
    May be anybody knows how to compile sources to get this library working in system.

  24. Installer Rails sur Windows « 29 minutes par jour : un blog anti-procrastination Says:

    [...] à faire. Il faut copier-coller le fichier libmysql.dll du dossier mysql vers le dossier ruby/bin. Merci à ce post pour m’avoir aidé sur ce coup [...]

  25. Sada Says:

    Thanks a lot!!!! Its works fine

  26. NeoOrion FreeStyle » Blog Archive » Ruby On Rails: Mi Nueva Aventura (II) Says:

    [...] de datos falla porque falta un archivo, tras una breve búsqueda doy a la primera con la solución: http://hillemania.wordpress.com/2006/09/21/rails-mysql-50-on-windows-setup-problemfix-libmysqldll/#c... Todo va bien de momento y creo el blog del manual. He conseguido completar el blog. Me gusta ROR! [...]

  27. xisoiax Says:

    Thank you very much.. now it works very fine….

  28. Shih-gian Lee Says:

    Thanks a lot! I use Mac or Linux most of the time and this blog save me a lot of time to get rails up and running on Widows.

Leave a Reply