The tutorial below is out of date. For up-to-date instructions please see one of the following:
__________
Automatically Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X
A bash script by Sakuzaku to automatically download and install:
Below is an installer package that fixes Ruby (by making a couple of changes to rbconfig.rb, and installing readline support so that the rails console will work). The package also installs rubygems, fcgi and rails in one fell swoop. You can find it by attached to the posting at my blog titled Rolling with Ruby on Rails on Mac OS X Tiger
You need to install the Xcode tools if you wish to use rubygems to compile native code extensions. This includes the mysql gem (which isn’t installed with this package).
To install the mysql gem please follow the instructions at: MySQL Bindings for Ruby under Mac OS X Tiger
Note from the author of this package (TonyArnold): Whilst I make no guarantees about this package, what it is doing is fairly straightforward. You’re welcome to message me using the AIM address: aim://arnantrsyd if you have any questions. This package does require Tiger, so please don’t try to install it on previous versions of the Mac OS, as it won’t work.
Locomotive is a flexible one-click solution to Ruby on Rails development for Mac OS X 10.3+. In one self-contained application, it gives you a fully functional Rails development platform including: (but not limited to)
Locomotive is designed with a fast-changing Rails world in mind and gives you a choice among Rails framework and web server bundles. The default bundles included with the Locomotive 0.4.1 distribution are:
Locomotive includes the Ruby MySQL and PostgreSQL bindings. If you have MySQL/PostgreSQL installed, or want to use them, Locomotive is ready. Locomotive will not break your current Rails setup. Locomotive is entirely self-contained.
The Rails 1.0.0 Min bundle includes:
The Rails 1.0.0 Max bundle is available seperately and includes everything in the Min bundle plus:
The lighttpd 1.4.6, FastCGI 2.4.0 web server bundle includes:
If you already have rubygems installed, simply open a terminal and type:
sudo gem install fixrbconfig; sudo fixrbconfig
You can also easily install all of the necessary software using DarwinPorts
If you are impatient, see HowtoInstallOnOSXTigerUsingDarwinPorts for step-by-step instructions on what to do.
First, download DarwinPorts 1.2 (installable packages available from their web site here) and follow their instructions for installation. Once you have done that, you can install ruby, rb-rubygems, fcgi, mysql and even lighttpd. The following command should work:
sudo port install rb-rubygems fcgi mysql
DarwinPorts also has many popular ruby extensions available directly, however for those available in .gem format, I prefer to use rubygems. Using rubygems, install mysql, sqlite3 (if you want to use sqlite3 which is now built into Tiger), and rails – and any other gems you wish to use. The following command should work:
gem install mysql sqlite3 rails
Download the fixed rbconfig.rb here:
Look through it and compare to the current version installed on your system (/usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb). You can simply copy the fixed version you’ve downloaded to the same location as the apple-installed version by typing:
sudo cp rbconfig.rb /usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb
But I’m going to assume that if you’ve read this far, you probably want to know why ruby is broken, or want to make the changes yourself. The version of ruby that Apple has included with Tiger is has a couple of things wrong with it (that we’ve found so far):
-arch i386 compiler flag. This flag does not seem to work when compiling native code extensions for rubygems, and I’d hazard to say the necessary files simply aren’t present in the Tiger developer tools for compiling i386 code on powerpc machines. When the Darwin 8.0 installers are released, it’s entirely likely ix86 users will need to make the opposite change to what we’ve done here and remove all references to -arch powerpc. You may notice that both -arch flags are removed if you simply copied over the fixed rbconfig.rb you downloaded above, or if you installed the Mac OS X Installer Package – the flag is completely unnecessary if you aren’t using a cross-compiler.CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static". This won’t work, as Apple has only included the dynamic library libruby.dylib, so you’ll need to change this line to reference nothing: CONFIG["LIBRUBYARG_STATIC"] = ""../script/console from within your rails app) doesn’t start because it is missing the readline library. You can install this yourself by installing GNU Readline, and recompiling the readline source in the ruby distribution. I’m not going to walk through that here, because if you don’t know how already you really shouldn’t be trying – just use the installer package at the top of this page.Once you’ve chosen a path and made the necessary changes/fixes, head back to the standard instructions for installing Rails under Mac OS X
which mysql” to find out where your mysql installation is.locate mysql_config” to see where your mysql_config binary is.sudo gcc_select 3.3” before installing the gem. (Don’t for get to switch back after.)I would highly recommend using DarwinPorts to install Ruby and any other software you need.
— Russ Smith
What version of MySQL should someone use to run on Tiger? I tried 4.0.24 but this seems to give problems. Is is safe to install 4.1.10 for OSX 10.3 on Tiger?
— Magirus
I’ve used MySQL 5.x and MySQL 4.x under Tiger without incident. Assuming your copy of mysql is installed in /usr/local/mysql you need to type:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Which will install the ruby mysql bindings for you. If you just run: sudo gem install mysql, you’ll get messages like ‘ERROR: While executing gem … (\RuntimeError) ERROR: Failed to build gem native extension’.
—TonyArnold
I had to install and use the fixrbconfig gem as described above, and install the mysql gem as described above to make Rails apps work correctly. Note that you’ll have to do these two steps in that order; the fixrbconfig gem allows you to build gems locally, which is required for the mysql gem. Takes no more than a couple of minutes to do this stuff.
—AndrewOtwell
Can you please detail the steps you needed to take? This would give novice users a more comfortable way into RoR
— Magirus
Yes, I’ll put together instructions in the next couple of days and post them here. Really, you should give the Mac OS X installer package a go if you haven’t.
—TonyArnold
Except none of this works, because, even after installing the Tiger Ruby fixes, Rails gives an ActiveRecord::StatementInvalid “No database selected” error when you try to query the MySQL database, and the ‘gem install mysql’ native build fails if you try to install the native MySQL bindings instead. You’ll probably need to run sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql instead of sudo gem install mysql as noted above. Honestly, I did. Following these instructions exactly, it still fails. The “fresh install” suggestion below is a great idea.
It would really be great if someone could do a fresh install in Tiger… I mean fresh-fresh, as in, do a clean install of Tiger and then do a step by step install of Ruby in its entirety. I’ve had nothing but trouble trying to get Rails going in Tiger and it would be great if an expert did it from scratch (honestly, it would be better if the tutorial didn’t use things like darwinports only because most of the darwinports don’t yet work in Tiger). —GM
Here’s details of install Rails and MySQL on a fresh install of Tiger:
http://jamie.blogthing.com/2005/05/12/installing-rails-on-a-fresh-tiger/
— JBRW
If you like me have problems with MySQL being unable to connect with a missing password, even though you’ve updated RoR, triple-checked the database.yml settings and so on, then just make sure that you run the sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql command, and all is working fine.
— MGP
I searched all over the web to get Rails on Tiger. I used Jamie’s instructions above to install Rails and I was still getting errors. I finally got it working and this is how I did it:
Installing Ruby on Rails on Tiger
Please let me know if this works for you or if I have to make changes to get it working correctly.
- Jose Marinez
To succesfully install the MySQL gem with Tiger Server (10.4.1), fill in your connection settings in database.yml and run this command: sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
— nicitz
Thank you, nicitz! This fix (above) was the one that I needed to get the mysql gem installed on Tiger server.
- HazMatt
But how will we run it on Leopard?
—MattMoriarity
After much struggling with Tiger and MySQL I realized that mysql wasn’t installed where I thought it was (installed from mysql.com binary). If you type ls /usr/local in the terminal, you can find the real directory. Then, change the install statement. For example, mine is sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql-standard-4.1.12-apple-darwin7.9.0-powerpc
-Daniel Morrison
If you don’t follow the instructions here, you’ll probably run into an error saying Before updating scaffolding from new DB schema, try creating a table for your model when you try to create a scaffold. Hopefully this page will now show up in searches for that phrase now.
If ‘gem install mysql’ if giving you an error 404. Install the Xcode tools from the Tiger DVD. Then download http://www.tmtm.org/en/mysql/ruby/mysql-ruby-2.5.2.tar.gz (not 2.6; this wouldn’t compile for me) and follow the installation instructions at http://www.tmtm.org/en/mysql/ruby/
This sorted the Before updating scaffolding from new DB schema, try creating a table for your model error for me.
- dctanner
I recently installed Rails on OS X 10.4.1 using the installer package above (option number 1). I installed MySQL 4.1.12 downloaded from the MySQL.org site. I also installed the other required packages / gems. When I went to test the scaffolding in a basic Rails app, I kept getting an “Access denied” error message. I knew my database.yml settings were correct, and I had the permissions set up correctly in MySQL. I could even log into the db from the Terminal. After 2 days of searching the web and asking in the IRC room, I finally was directed to the Ruby MySQL API module. I installed it, and was off and running. I would add this module to the list of items to install on OS X 10.4. At the very least, keep it in mind if you run into MySQL issues.
- Phil
I did a which mysql and found it to be /sw/bin/mysql… but it still didn’t work until i used /usr/local/mysql
— Bryce
I was getting a strange error ‘ERROR: Error installing gem mysql[.gem]: string contains null byte’ so I forced gems to do a remote install:
sudo gem install -r mysql -- --with-mysql-dir=/usr/local/mysql-standard-4.1.12-apple-darwin7.9.0-powerpc/
and it appears to have worked.
—Ben
I confirm that the above mentionned solution works fine.
To change gcc to v 3.3, type this :
$ sudo gcc_select 3.3
— Thomas Balthazar.
Referencing the full directory is probably not needed. The orginal instructions were missing a ‘-’, and so it was probably a cut-and-paste error. I changed them from this:
sudo gem install mysql -- -with-mysql-dir=/usr/local/mysqlto this:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysqland it worked for me.
—Tim S.
— Etienne Gonnaud
I had no luck at all with the gems install of mysql [10.4.1 w/ XCode 2.1 and the official MySQL package for 4.1.13, and the system install of Ruby but with rbconf fixed]. Instead, I used the downloadable MySQL/Ruby package (from tmtm.org, linked below) and the --with-mysql-config flag pointing at /usr/local/mysql/bin/mysql_config.
Using mysql_config prevents Ruby from trying to find and verify libmysqlclient.a itself, which wasn’t working.
— Pete Hopkins
For those who followed the above instructions for Tiger and still have the “update Table error” when generating scaffold, I’ve solved this through the MySQL/Ruby package and its proper instructions.
***********
And if you’re still having problems, I have it pretty much step by step how to do it here (including the manual mysql ruby gem install): http://www.pjhyett.com/articles/2005/06/04/setting-up-ror-in-tiger
***********
I was having multiple problems which can be read about on this site:
http://habtm.com/articles/2005/08/04/installing-ruby-mysql-bindings-2-6-on-tiger-troubleshooting
I managed to get this working with Tiger doing the following:
sudo gcc_select 4.0
ruby extconf.rb --with-mysql-config
make
sudo make install
I then started up the server for my Rails app, and with scaffolding it now works fine. I’m so glad that it works now. – David Winter
************If you keep gettting this:
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
try
sudo gem install mysql -- --with-mysql-include=/usr/local/mysql/include/ --with-mysql-lib=/usr/local/mysql/lib/ --with-mysql-config=/usr/local/mysql/bin/mysql_config
it worked for me.
—-note: This work for me also, under Panther. Thank you, HazMatt
************
After getting the “checking for mysql_query()” errors, this worked for me on 10.4.2
sudo gcc_select 3.3
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-include=/usr/local/mysql/include/ --with-mysql-lib=/usr/local/mysql/lib/ --with-mysql-config=/usr/local/mysql/bin/mysql_config
****************************************
I worked on this for ages, reinstalled Ruby, MySQL and Rails at least three times each and tried to compile the mysql gem with all different varieties above. None worked – either I would get a compilation error (with the —with-mysql-dir variety) or the compilation would seem to go fine, for the Rails server inadvertently then to crash on a “Missing Symbol” error. For a technology promising to bring up web development productivity 10 fold, this was extremely discouraging.
What turned out to be the problem? The compiler needs the libmysqlclient.so (?) mysql library file to build the gem against. But each of the Mac OS X binaries I installed from MySQL.com, are distributed without this library. So no wonder the compiler could not compile successfully: it is missing a key component that is simply not installed when you are following the installation instructions (install the latest MySQL binary) above. I’m wondering why I seem to be the first to notice this?
Anyway, the solution takes a bit more time but is relatively simple. In stead of installing a binary, scroll down the MySQL distribution list and download the source code distribution. Follow the instructions in the INSTALL file to install this copy on your system, just remember to do ‘sudo make install’ in stead of ‘make install’ I even installed it on a different location /opt/mysql so as not to overwrite my standard binary installation on /usr/local/mysql . Afterwards the instructions above (sudo gcc_select … , sudo gem install …) work like a charm and my Ruby on Rails is finally working now. :-)
(( NOTE: easier solution… fink has the shared lib package… e.g. [http://pdb.finkproject.org/pdb/package.php/mysql14-shlibs here] ))
For the people maintaining the installation packages and gems – has nobody ever noticed that this key libmysqlclient.so file is missing from the MacOSX? binary of MySQL?
****************************************
I’d been trying to install any mysql connector (2.5, 2.6 & 2.7) over the last week on OS X 10.4.2 with MySQL 4.1.13 and always got either the no mysql.h error (when I tried to install manually with ‘ruby extconf.sh’ etc.) or the checking for mysql_query() in -lmysqlclient… no error when trying to use Gems.
Checking in with another OS X user who’d succesfully installed the connector I found he was using 4.1.12 so I replaced 4.1.13 by shutting down MySQL and using the command line to move the /usr/local/mysql-whichever_version_you’re_running and the mysql symlink into my user directory. Initially, 4.1.12 refused to install which I suspected was due to it finding the installer receipt for .13 in the /Library/Receipts folder so I removed it and .12 went in fine.
Using the Gem method, mysql installed first time even though I still got those checking for mysql_query() in -lmysqlclient… no errors I’d had before.
+ Update +
While this solution worked fine on my Mac Mini it didn’t seem to fix the problem on my office G4 so mileage is definately going to vary!
***************************************************
The difference between the descriptions that work, and the descriptions that don’t work, is that the ones that do work use the 2.7beta2 mysql bindings, and not whatever version gem would use on its own. Using them, I’ve gotten two machines to install a working setup of rails, when several tries before left me with nothing but frustration. READ Tony Arnold’s description here, and follow these instructions:
http://www.tonyarnold.com/articles/2005/08/11/mysql-bindings-for-ruby-under-mac-os-x-tiger
****************************************************
I’ve just found that the suggestions made on this page work only on my machine if I use GCC 4.0, not 3.3 as recommended.
****************************************************
If you’ve just upgraded to Tiger, and you’ve also upgraded MySQL, it’s really worth noting that MySQL4.1+ changes the way it handles passwords. 4.1.x versions of MySQL use a new password hashing function that is not compatible with the older client libraries — in short, the upgrade will break most of your previous (PHP, what have you) apps if you don’t startup MySQL using the —old-passwords option.
*****************************************************
I tried to keep a running list of the individual problems and their causes as I went along:
http://www.evilrob.org/journal/archives/000198.html
Hope this helps you if something about your config isn’t right. It’s no new magic steps in fixing things that aren’t on this page, but it does have each problem and it’s cause. And I think I hit all the problems. :-)
****************************************************
Any advice on getting this working on OS X server?
I’m installing onto Mac OS X Server running 10.4, and unfortunately, installing the dev tools on this machine is not currently an option. Is there a way to get the mysql plugin installed without them? Maybe a precompiled binary? It’s a pretty vanilla machine on the whole…
When I try to install it with gem install myql, i get a runtime error (because the dev tools are not installed, no doubt).
sam
*****************************************************
If you’re looking for a step-by-step install of ruby, rails, lighttpd, and their pre-requisites, hivelogic has just put up a post here:
Building Ruby, Rails, LightTPD, and MySQL on Tiger
~~ I did just that, today Oct 16 2006, on a fresh G4-ppc 10.4; it does not work, something very basic is wrong with the readline library and ruby interaction
*****************************************************
Every method i tried always brings up the “Before updating scaffolding from new DB schema, try creating a table for your model” whenever i try to create a scaffold. Running “rake migrate” des not seem to create any table in the mysql database.
The tutorial below is out of date. For up-to-date instructions please see one of the following:
__________
Automatically Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X
A bash script by Sakuzaku to automatically download and install:
Below is an installer package that fixes Ruby (by making a couple of changes to rbconfig.rb, and installing readline support so that the rails console will work). The package also installs rubygems, fcgi and rails in one fell swoop. You can find it by attached to the posting at my blog titled Rolling with Ruby on Rails on Mac OS X Tiger
You need to install the Xcode tools if you wish to use rubygems to compile native code extensions. This includes the mysql gem (which isn’t installed with this package).
To install the mysql gem please follow the instructions at: MySQL Bindings for Ruby under Mac OS X Tiger
Note from the author of this package (TonyArnold): Whilst I make no guarantees about this package, what it is doing is fairly straightforward. You’re welcome to message me using the AIM address: aim://arnantrsyd if you have any questions. This package does require Tiger, so please don’t try to install it on previous versions of the Mac OS, as it won’t work.
Locomotive is a flexible one-click solution to Ruby on Rails development for Mac OS X 10.3+. In one self-contained application, it gives you a fully functional Rails development platform including: (but not limited to)
Locomotive is designed with a fast-changing Rails world in mind and gives you a choice among Rails framework and web server bundles. The default bundles included with the Locomotive 0.4.1 distribution are:
Locomotive includes the Ruby MySQL and PostgreSQL bindings. If you have MySQL/PostgreSQL installed, or want to use them, Locomotive is ready. Locomotive will not break your current Rails setup. Locomotive is entirely self-contained.
The Rails 1.0.0 Min bundle includes:
The Rails 1.0.0 Max bundle is available seperately and includes everything in the Min bundle plus:
The lighttpd 1.4.6, FastCGI 2.4.0 web server bundle includes:
If you already have rubygems installed, simply open a terminal and type:
sudo gem install fixrbconfig; sudo fixrbconfig
You can also easily install all of the necessary software using DarwinPorts
If you are impatient, see HowtoInstallOnOSXTigerUsingDarwinPorts for step-by-step instructions on what to do.
First, download DarwinPorts 1.2 (installable packages available from their web site here) and follow their instructions for installation. Once you have done that, you can install ruby, rb-rubygems, fcgi, mysql and even lighttpd. The following command should work:
sudo port install rb-rubygems fcgi mysql
DarwinPorts also has many popular ruby extensions available directly, however for those available in .gem format, I prefer to use rubygems. Using rubygems, install mysql, sqlite3 (if you want to use sqlite3 which is now built into Tiger), and rails – and any other gems you wish to use. The following command should work:
gem install mysql sqlite3 rails
Download the fixed rbconfig.rb here:
Look through it and compare to the current version installed on your system (/usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb). You can simply copy the fixed version you’ve downloaded to the same location as the apple-installed version by typing:
sudo cp rbconfig.rb /usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb
But I’m going to assume that if you’ve read this far, you probably want to know why ruby is broken, or want to make the changes yourself. The version of ruby that Apple has included with Tiger is has a couple of things wrong with it (that we’ve found so far):
-arch i386 compiler flag. This flag does not seem to work when compiling native code extensions for rubygems, and I’d hazard to say the necessary files simply aren’t present in the Tiger developer tools for compiling i386 code on powerpc machines. When the Darwin 8.0 installers are released, it’s entirely likely ix86 users will need to make the opposite change to what we’ve done here and remove all references to -arch powerpc. You may notice that both -arch flags are removed if you simply copied over the fixed rbconfig.rb you downloaded above, or if you installed the Mac OS X Installer Package – the flag is completely unnecessary if you aren’t using a cross-compiler.CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static". This won’t work, as Apple has only included the dynamic library libruby.dylib, so you’ll need to change this line to reference nothing: CONFIG["LIBRUBYARG_STATIC"] = ""../script/console from within your rails app) doesn’t start because it is missing the readline library. You can install this yourself by installing GNU Readline, and recompiling the readline source in the ruby distribution. I’m not going to walk through that here, because if you don’t know how already you really shouldn’t be trying – just use the installer package at the top of this page.Once you’ve chosen a path and made the necessary changes/fixes, head back to the standard instructions for installing Rails under Mac OS X
which mysql” to find out where your mysql installation is.locate mysql_config” to see where your mysql_config binary is.sudo gcc_select 3.3” before installing the gem. (Don’t for get to switch back after.)I would highly recommend using DarwinPorts to install Ruby and any other software you need.
— Russ Smith
What version of MySQL should someone use to run on Tiger? I tried 4.0.24 but this seems to give problems. Is is safe to install 4.1.10 for OSX 10.3 on Tiger?
— Magirus
I’ve used MySQL 5.x and MySQL 4.x under Tiger without incident. Assuming your copy of mysql is installed in /usr/local/mysql you need to type:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Which will install the ruby mysql bindings for you. If you just run: sudo gem install mysql, you’ll get messages like ‘ERROR: While executing gem … (\RuntimeError) ERROR: Failed to build gem native extension’.
—TonyArnold
I had to install and use the fixrbconfig gem as described above, and install the mysql gem as described above to make Rails apps work correctly. Note that you’ll have to do these two steps in that order; the fixrbconfig gem allows you to build gems locally, which is required for the mysql gem. Takes no more than a couple of minutes to do this stuff.
—AndrewOtwell
Can you please detail the steps you needed to take? This would give novice users a more comfortable way into RoR
— Magirus
Yes, I’ll put together instructions in the next couple of days and post them here. Really, you should give the Mac OS X installer package a go if you haven’t.
—TonyArnold
Except none of this works, because, even after installing the Tiger Ruby fixes, Rails gives an ActiveRecord::StatementInvalid “No database selected” error when you try to query the MySQL database, and the ‘gem install mysql’ native build fails if you try to install the native MySQL bindings instead. You’ll probably need to run sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql instead of sudo gem install mysql as noted above. Honestly, I did. Following these instructions exactly, it still fails. The “fresh install” suggestion below is a great idea.
It would really be great if someone could do a fresh install in Tiger… I mean fresh-fresh, as in, do a clean install of Tiger and then do a step by step install of Ruby in its entirety. I’ve had nothing but trouble trying to get Rails going in Tiger and it would be great if an expert did it from scratch (honestly, it would be better if the tutorial didn’t use things like darwinports only because most of the darwinports don’t yet work in Tiger). —GM
Here’s details of install Rails and MySQL on a fresh install of Tiger:
http://jamie.blogthing.com/2005/05/12/installing-rails-on-a-fresh-tiger/
— JBRW
If you like me have problems with MySQL being unable to connect with a missing password, even though you’ve updated RoR, triple-checked the database.yml settings and so on, then just make sure that you run the sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql command, and all is working fine.
— MGP
I searched all over the web to get Rails on Tiger. I used Jamie’s instructions above to install Rails and I was still getting errors. I finally got it working and this is how I did it:
Installing Ruby on Rails on Tiger
Please let me know if this works for you or if I have to make changes to get it working correctly.
- Jose Marinez
To succesfully install the MySQL gem with Tiger Server (10.4.1), fill in your connection settings in database.yml and run this command: sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
— nicitz
Thank you, nicitz! This fix (above) was the one that I needed to get the mysql gem installed on Tiger server.
- HazMatt
But how will we run it on Leopard?
—MattMoriarity
After much struggling with Tiger and MySQL I realized that mysql wasn’t installed where I thought it was (installed from mysql.com binary). If you type ls /usr/local in the terminal, you can find the real directory. Then, change the install statement. For example, mine is sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql-standard-4.1.12-apple-darwin7.9.0-powerpc
-Daniel Morrison
If you don’t follow the instructions here, you’ll probably run into an error saying Before updating scaffolding from new DB schema, try creating a table for your model when you try to create a scaffold. Hopefully this page will now show up in searches for that phrase now.
If ‘gem install mysql’ if giving you an error 404. Install the Xcode tools from the Tiger DVD. Then download http://www.tmtm.org/en/mysql/ruby/mysql-ruby-2.5.2.tar.gz (not 2.6; this wouldn’t compile for me) and follow the installation instructions at http://www.tmtm.org/en/mysql/ruby/
This sorted the Before updating scaffolding from new DB schema, try creating a table for your model error for me.
- dctanner
I recently installed Rails on OS X 10.4.1 using the installer package above (option number 1). I installed MySQL 4.1.12 downloaded from the MySQL.org site. I also installed the other required packages / gems. When I went to test the scaffolding in a basic Rails app, I kept getting an “Access denied” error message. I knew my database.yml settings were correct, and I had the permissions set up correctly in MySQL. I could even log into the db from the Terminal. After 2 days of searching the web and asking in the IRC room, I finally was directed to the Ruby MySQL API module. I installed it, and was off and running. I would add this module to the list of items to install on OS X 10.4. At the very least, keep it in mind if you run into MySQL issues.
- Phil
I did a which mysql and found it to be /sw/bin/mysql… but it still didn’t work until i used /usr/local/mysql
— Bryce
I was getting a strange error ‘ERROR: Error installing gem mysql[.gem]: string contains null byte’ so I forced gems to do a remote install:
sudo gem install -r mysql -- --with-mysql-dir=/usr/local/mysql-standard-4.1.12-apple-darwin7.9.0-powerpc/
and it appears to have worked.
—Ben
I confirm that the above mentionned solution works fine.
To change gcc to v 3.3, type this :
$ sudo gcc_select 3.3
— Thomas Balthazar.
Referencing the full directory is probably not needed. The orginal instructions were missing a ‘-’, and so it was probably a cut-and-paste error. I changed them from this:
sudo gem install mysql -- -with-mysql-dir=/usr/local/mysqlto this:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysqland it worked for me.
—Tim S.
— Etienne Gonnaud
I had no luck at all with the gems install of mysql [10.4.1 w/ XCode 2.1 and the official MySQL package for 4.1.13, and the system install of Ruby but with rbconf fixed]. Instead, I used the downloadable MySQL/Ruby package (from tmtm.org, linked below) and the --with-mysql-config flag pointing at /usr/local/mysql/bin/mysql_config.
Using mysql_config prevents Ruby from trying to find and verify libmysqlclient.a itself, which wasn’t working.
— Pete Hopkins
For those who followed the above instructions for Tiger and still have the “update Table error” when generating scaffold, I’ve solved this through the MySQL/Ruby package and its proper instructions.
***********
And if you’re still having problems, I have it pretty much step by step how to do it here (including the manual mysql ruby gem install): http://www.pjhyett.com/articles/2005/06/04/setting-up-ror-in-tiger
***********
I was having multiple problems which can be read about on this site:
http://habtm.com/articles/2005/08/04/installing-ruby-mysql-bindings-2-6-on-tiger-troubleshooting
I managed to get this working with Tiger doing the following:
sudo gcc_select 4.0
ruby extconf.rb --with-mysql-config
make
sudo make install
I then started up the server for my Rails app, and with scaffolding it now works fine. I’m so glad that it works now. – David Winter
************If you keep gettting this:
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
try
sudo gem install mysql -- --with-mysql-include=/usr/local/mysql/include/ --with-mysql-lib=/usr/local/mysql/lib/ --with-mysql-config=/usr/local/mysql/bin/mysql_config
it worked for me.
—-note: This work for me also, under Panther. Thank you, HazMatt
************
After getting the “checking for mysql_query()” errors, this worked for me on 10.4.2
sudo gcc_select 3.3
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-include=/usr/local/mysql/include/ --with-mysql-lib=/usr/local/mysql/lib/ --with-mysql-config=/usr/local/mysql/bin/mysql_config
****************************************
I worked on this for ages, reinstalled Ruby, MySQL and Rails at least three times each and tried to compile the mysql gem with all different varieties above. None worked – either I would get a compilation error (with the —with-mysql-dir variety) or the compilation would seem to go fine, for the Rails server inadvertently then to crash on a “Missing Symbol” error. For a technology promising to bring up web development productivity 10 fold, this was extremely discouraging.
What turned out to be the problem? The compiler needs the libmysqlclient.so (?) mysql library file to build the gem against. But each of the Mac OS X binaries I installed from MySQL.com, are distributed without this library. So no wonder the compiler could not compile successfully: it is missing a key component that is simply not installed when you are following the installation instructions (install the latest MySQL binary) above. I’m wondering why I seem to be the first to notice this?
Anyway, the solution takes a bit more time but is relatively simple. In stead of installing a binary, scroll down the MySQL distribution list and download the source code distribution. Follow the instructions in the INSTALL file to install this copy on your system, just remember to do ‘sudo make install’ in stead of ‘make install’ I even installed it on a different location /opt/mysql so as not to overwrite my standard binary installation on /usr/local/mysql . Afterwards the instructions above (sudo gcc_select … , sudo gem install …) work like a charm and my Ruby on Rails is finally working now. :-)
(( NOTE: easier solution… fink has the shared lib package… e.g. [http://pdb.finkproject.org/pdb/package.php/mysql14-shlibs here] ))
For the people maintaining the installation packages and gems – has nobody ever noticed that this key libmysqlclient.so file is missing from the MacOSX? binary of MySQL?
****************************************
I’d been trying to install any mysql connector (2.5, 2.6 & 2.7) over the last week on OS X 10.4.2 with MySQL 4.1.13 and always got either the no mysql.h error (when I tried to install manually with ‘ruby extconf.sh’ etc.) or the checking for mysql_query() in -lmysqlclient… no error when trying to use Gems.
Checking in with another OS X user who’d succesfully installed the connector I found he was using 4.1.12 so I replaced 4.1.13 by shutting down MySQL and using the command line to move the /usr/local/mysql-whichever_version_you’re_running and the mysql symlink into my user directory. Initially, 4.1.12 refused to install which I suspected was due to it finding the installer receipt for .13 in the /Library/Receipts folder so I removed it and .12 went in fine.
Using the Gem method, mysql installed first time even though I still got those checking for mysql_query() in -lmysqlclient… no errors I’d had before.
+ Update +
While this solution worked fine on my Mac Mini it didn’t seem to fix the problem on my office G4 so mileage is definately going to vary!
***************************************************
The difference between the descriptions that work, and the descriptions that don’t work, is that the ones that do work use the 2.7beta2 mysql bindings, and not whatever version gem would use on its own. Using them, I’ve gotten two machines to install a working setup of rails, when several tries before left me with nothing but frustration. READ Tony Arnold’s description here, and follow these instructions:
http://www.tonyarnold.com/articles/2005/08/11/mysql-bindings-for-ruby-under-mac-os-x-tiger
****************************************************
I’ve just found that the suggestions made on this page work only on my machine if I use GCC 4.0, not 3.3 as recommended.
****************************************************
If you’ve just upgraded to Tiger, and you’ve also upgraded MySQL, it’s really worth noting that MySQL4.1+ changes the way it handles passwords. 4.1.x versions of MySQL use a new password hashing function that is not compatible with the older client libraries — in short, the upgrade will break most of your previous (PHP, what have you) apps if you don’t startup MySQL using the —old-passwords option.
*****************************************************
I tried to keep a running list of the individual problems and their causes as I went along:
http://www.evilrob.org/journal/archives/000198.html
Hope this helps you if something about your config isn’t right. It’s no new magic steps in fixing things that aren’t on this page, but it does have each problem and it’s cause. And I think I hit all the problems. :-)
****************************************************
Any advice on getting this working on OS X server?
I’m installing onto Mac OS X Server running 10.4, and unfortunately, installing the dev tools on this machine is not currently an option. Is there a way to get the mysql plugin installed without them? Maybe a precompiled binary? It’s a pretty vanilla machine on the whole…
When I try to install it with gem install myql, i get a runtime error (because the dev tools are not installed, no doubt).
sam
*****************************************************
If you’re looking for a step-by-step install of ruby, rails, lighttpd, and their pre-requisites, hivelogic has just put up a post here:
Building Ruby, Rails, LightTPD, and MySQL on Tiger
~~ I did just that, today Oct 16 2006, on a fresh G4-ppc 10.4; it does not work, something very basic is wrong with the readline library and ruby interaction
*****************************************************
Every method i tried always brings up the “Before updating scaffolding from new DB schema, try creating a table for your model” whenever i try to create a scaffold. Running “rake migrate” des not seem to create any table in the mysql database.