It´s really a hard job figuring out how to get MySQL and mysql gem up and running on Snow Leopard 10.6.2. I followed the instructions of various posts but was not successful yet:
I build MySQL Version 5.1.39 from source and it installed successfully. When trying to login using (mysql -u root -p) mysql returned the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
that obviously meant that the MySQL Server (mysqld) was not running.
which mysql: /usr/local/mysql/bin/mysql
which ruby: ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9])
gem -v: 1.3.5
mysql: Server version: 5.1.39 MySQL Community Server (GPL)
After a lot of googling around, I found out that
this command can start mysqld:
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
The Preference Pane MySQL Tool is probably broken in Mac OS X 10.5 and higher
This command should install the mysql gem correctly on Snow Leopard:
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
It ended up that I got the following error using something like rake db:create:
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_init
Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
This error led me to the following post: http://cho.hapgoods.com/wordpress/?p=158, that basically tells me that the Ruby Version that came together with XCode 3.0 does not work in 64bit environments and a solution could be to install the 32bit versionof MySQL.
Any suggestions, how to proceed?
While building from source is not necessarily a bad idea, even if the official distribution is built using a better compiler, using MacPorts (http://www.macports.org/install.php) to do it is probably a better idea than a self-built installation.
Although you can wrangle the OS X supplied Ruby and MySQL into shape, in my experience it's easier to work entirely within the MacPorts realm (/opt) and leave your original distribution unmolested.
A further advantage is you get a more up-to-date Ruby executable. 10.6 ships with 1.8.7p72 where MacPorts provides 1.8.7p174, for instance.
Example:
sudo port install mysql5
sudo port install mysql5-server
sudo port install rb-mysql
Related
I'm trying to use Rails with the MySQL bin from Ampps, but when I run the command rails generate scaffold User name:string email:string I get the following error:
dyld: lazy symbol binding failed: Symbol not found: _mysql_server_init
Referenced from: /Users/myusername/.rvm/gems/ruby-2.2.1/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_server_init
Referenced from: /Users/myusername/.rvm/gems/ruby-2.2.1/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
I have already configured Ampps Mysql with my environment but I can not managed to make it work with rails, I have the following configurations.
$ which mysql
/Applications/AMPPS/mysql/bin/mysql
$ echo $PATH
/Users/myusername/.rvm/gems/ruby-2.2.1/bin:/Users/myusername/.rvm/gems/ruby-2.2.1#global/bin:/Users/myusername/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/myusername/.rvm/gems/ruby-2.2.1/bin:/Users/myusername/.rvm/gems/ruby-2.2.1#global/bin:/Users/myusername/.rvm/rubies/ruby-2.2.1/bin:/Applications/AMPPS/php-5.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/myusername/.rvm/bin:/Users/myusername/.rvm/bin:/Applications/AMPPS/mysql/bin
$ ls -l /usr/local/lib/libmy*.dylib
lrwxr-xr-x 1 myusername admin 53 Jan 1 19:30 /usr/local/lib/libmysqlclient.18.dylib -> /Applications/AMPPS/mysql/lib/libmysqlclient.18.dylib
I have tried doing commands but with no success:
$ gem install mysql2 -- --with-mysql-lib=/Applications/AMPPS/mysql/lib --with-mysql-include=/Applications/AMPPS/mysql/include --with-mysql-config=/Applications/AMPPS/mysql/bin/mysql_config
And
bundle config build.mysql2 --with-mysql-lib=/Applications/AMPPS/mysql/lib --with-mysql-include=/Applications/AMPPS/mysql/include --with-mysql-config=/Applications/AMPPS/mysql/bin/mysql_config
bundle install
Any ideas?
I downloaded this AMPPS package and did a quick check on the MySQL binary:
$ file /Volumes/AMPPS/AMPPS/mysql/bin/mysql
/Volumes/AMPPS/AMPPS/mysql/bin/mysql: Mach-O executable i386
Your 64-bit Ruby install is trying to link to 32-bit MySQL libraries, and is not finding what it's looking for. "Symbol not found" errors are often an indication of an architecture mismatch.
My advice to you would be to install these programs from a package management system such as MacPorts or Homebrew. I'm partial to MacPorts, so I'll give you instructions for that. I get the impression Homebrew is more popular, but haven't used it myself.
Install Xcode and the Xcode Command Line Tools
Agree to Xcode license in Terminal: sudo xcodebuild -license
Install MacPorts: https://distfiles.macports.org/MacPorts/MacPorts-2.3.4-10.11-ElCapitan.pkg
Update the port list: sudo port selfupdate
Install away: sudo port install mysql56 rb-rails rb-mysql
Update regularly: sudo port selfupdate && sudo port -uc upgrade outdated
This way you're getting properly built binaries for your system, you can easily keep them up to date, and you aren't filling your system up with 2 gigabytes of things you aren't necessarily going to use (5 different versions of PHP, a couple of database servers, Perl, Python, etc.) In addition, you also get up-to-date versions of other utilities like Ruby, rather than relying on the outdated version that ships with the operating system.
I'm attempting to install a previous version of MySql (5.5.31) on my Mac OSX device running 10.9 Mavericks. I have been told this is possible, however, I cannot seem to locate a download for 5.5.31 Mac OSX.
I have a later version (5.6.19) installed, and I tried:
brew switch mysql 5.5.31
but I keep getting the error message:
"Error: mysql not found in the Cellar."
And I know this is because there's no 5.5.31 MySql file for it to switch to.
Anyone do this on their Mac?
Thanks
This is an old question, but I stumbled upon it through Google, so here's to anyone to stumbles upon it later.
I was trying to install MySQL 5.5 on OS X 10.10 through Homebrew.
First, you have to add homebrew/versions to your taps with:
$ homebrew tap homebrew/versions
Second, install MySQL 5.5 with:
$ homebrew install mysql55
if that doesn't work, try:
$ homebrew install homebrew/versions/mysql55
After that has successfully installed, you will get the message:
...A "/etc/my.cnf" from another install may interfere with a
Homebrew-built server starting up correctly.
To connect:
mysql -uroot
To load mysql55:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql55.plist Or, if you don't want/need launchctl, you can just run:
mysql.server start ❯ cd /usr/local/Cellar/mys
Try mysql.server start, if that doesn't work you need to update your $PATH. In my case I added /usr/local/Cellar/mysql55/5.5.40/bin to my $PATH in my .zshrc. You can find the location of your installation by using:
$ homebrew info mysql55
After that it should work after you've added that directory to your .zshrc/.bashrc/.bash_profile etc.
I'm trying to get ruby on rails working nicely with MySQL on Mac OS X 10.7.4. I've run into the following issue (I have gem 'mysql2' in my Gemfile):
dlopen(/Users/Ringo/.rvm/gems/ruby-1.9.3-p194#gemset/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
A couple of potential issues: I have installed mysql with the dmg available here: http://dev.mysql.com/downloads/mysql/
I don't know if I need some specific mysql client libraries or what. I didn't have to specify a mysql username / password even when I installed that. I did install the prefpane that comes with it and the claim is that mysql is running.
That's an easy one:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
I am trying to get the mysql gem to work ... and it just doesn't want to. Every time I do a rake db:migrate, I get
uninitialized constant MysqlCompat::MysqlRes
I've installed mysql from this disk image: mysql-5.5.9-osx10.6-x86_64.dmg
I've run the gem install with the infamous archflags setting:
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
And the ruby version I'm using is the default from Snow Leopard:
[~/sites/testdb]$ file `which mysql`
/usr/local/mysql/bin/mysql: Mach-O 64-bit executable x86_64
[~/sites/testdb]$ file `which ruby`
/usr/bin/ruby: Mach-O universal binary with 3 architectures
/usr/bin/ruby (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/ruby (for architecture i386): Mach-O executable i386
/usr/bin/ruby (for architecture ppc7400): Mach-O executable ppc
My database.yml is pretty simple:
development:
adapter: mysql
host: 127.0.0.1
database: testdb
username: root
password:
Any help would be appreciated.
You can easy fix your problem.
If you don't use rvm:
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundleruby
If you use rvm:
install_name_tool -change libmysqlclient.16.dylib usr/local/mysql/lib/libmysqlclient.16.dylib [YOUR_GEMSET_PATH]/gems/mysql-2.8.1/lib/mysql_api.bundle
I blogged about this last week: MySQL 5.5 on Mac OS X.
My alternate solution to using install_name_tool is to set DYLD_LIBRARY_PATH in your shell startup files. The advantage to this you do it once, whereas if you use install_name_tool, you will repeat that every time to re-install or upgrade the gem.
The mysql2 gem will have the same problem with a slightly different error message. The problem is how the libmysqlclient library is built. It doesn't include a full path, so anything linking with it can't find it at runtime.
I ran into the same error. On my machine, though, the mysql gen was built when I still had mysql 5.1 on my machine. Now, after upgrading to MySQL 5.5, the dyld-file referred by the original build /usr/local/mysql/lib/libmysqlclient.16.dylib didn't exist any more and was replaced by a file /usr/local/mysql/lib/libmysqlclient.18.dylib.
Completely rebuilding the mysql gem fixed things, i.e.
gem uninstall mysql
gem install mysql
You could try using the mysql2 gem which may not suffer from the same problems.
I've found it's often a lot better to use ruby and mysql from MacPorts or brew to keep everything on the same page and not mess with the system Ruby.
OS X comes with a version of MySQL that may not match up with what you have installed, or perhaps the gem installer is confused about which config program to use. Make sure mysql_config is returning the correct path.
I've been fighting with getting the MySQL Ruby Gem up and running on Snow Leopard for the past couple of days.
I have tried all different sorts of things to get this working, and currently have MySQL 5.1.37 x64 installed. After fighting to even get the Gem installed I believe that I finally got it installed, but whenever I attempt to access my Rails site I immediately receive the following error:
/!\ FAILSAFE /!\ Tue Sep 01 21:47:23 -0500 2009
Status: 500 Internal Server Error
Client does not support authentication protocol requested by server; consider upgrading MySQL client
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:453:in `read'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:130:in `real_connect'
The remote server I am attempting to connect to is running MySQL version 5.0.70, and can be connected to by other clients (including Sequel Pro running from my machine).
Here are some of the versions of software currently installed on my machine:
MySQL 5.1.37 OS X 10.5 x86-64
Ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
Gem version 1.3.5
I have read other accounts of people getting this working on Snow Leopard, so surely I've missed a step. Any advise would be greatly appreciated.
Thanks!
There's a post about this that basically says:
Compile it from source using: CC=gcc CFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-arch x86_64 -O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared --with-plugins=innobase && make && sudo make install
Install the mysql gem with: sudo env ARCHFLAGS="-arch x86\_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I did this and it works for me.
on the official weblog of ruby on rails they told something about leopard
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard