Setup Mysql / rails 3.0.3 Snow leopard 32bit

Hi everybody,

Can someone tell me how i can set up Rails 3.0.3 working with mysql on
Snow Leopard 32bit? i’ve tried adding the gem ‘mysql2’ in my gem file
and run ‘bundle install’ with the database.yml set to:

development:
adapter: mysql2
database: rails_mysql_database
username: root
password: root

With the setup as above, when i run $ rails generate scaffold test
name:string
invoke active_record
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/yaml.rb:133:in load': syntax error on line 15, col 0:test:’ (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/yaml.rb:133:in load' from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/ configuration.rb:88:indatabase_configuration’
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/
railtie.rb:58
and the list goes on with errors like above…

Since i already had some trouble getting mysql to work with rails, i
thought maby somebody here can help me with this? mysql is working
fine and a connection with php is no problem. When i google it i only
find people having trouble setting up mysql with rails 3 but no
solutions. I don’t use macports or rvm… just rubygems

Hope one of you can help me out?

Thanks in advance!

$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
$ rails --version
Rails 3.0.3
$ gem --version
1.4.2
$ sudo /usr/local/mysql/bin/mysqladmin
Ver 8.42 Distrib 5.1.54, for apple-darwin10.3.0 on i386

On Jan 9, 1:52pm, Daniel A. [email protected] wrote:

Hi everybody,

Can someone tell me how i can set up Rails 3.0.3 working with mysql on
Snow Leopard 32bit? i’ve tried adding the gem ‘mysql2’ in my gem file
and run ‘bundle install’ with the database.yml set to:

Sounds like a syntax error in your database.yml file. Make sure you’re
using spaces and not tabs, be wary of special characters.

Fred

Thx Frederick,

You where right about the syntax error in the database.yml… think i
used tabs. So the scaffold command works now but if it try to run: $
rake db:migrate
(in /Users/daniel/Sites/rails_mysql)
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/
mysql2.bundle
Expected in: flat namespace

dyld: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/
mysql2.bundle
Expected in: flat namespace

Trace/BPT trap

Can you help me out with this one?

Thx!

On Jan 9, 2:15pm, Daniel A. [email protected] wrote:

dyld: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/
mysql2.bundle
Expected in: flat namespace

Trace/BPT trap

Can you help me out with this one?

Something’s buggered with your mysql2 gem. I’d check what architecture
mysql2.bundle is (use lipo -detailed_info), compare that with the ruby
executable and the mysql libraries
You might want to reinstall it, telling the install to use the
mysql_config program, so that it picks up the right compile settings
(something like gem install mysql2 – --with-mysql-config=/usr/local/
mysql/bin/mysql_config (obviously adjusting to where your mysql_config
binary actually is)

Fred

On Jan 9, 4:15pm, Daniel A. [email protected] wrote:

Any ideas?

It usually means that rails couldn’t load the connection adapter. You
should get a more specific error if you open an irb session and
require ruby gems and then mysql2. You want to make sure that you have
the right version of mysql (the x86-64 version if you have anything
but one of the very first intel machines)

Fred

okee, i’ve reinstalled the gem, usr/local/mysql/bin/mysql_config is
the correct path.


$ gem install mysql2 – --with-mysql-config=/usr/local/mysql/bin/
mysql_config
Fetching: mysql2-0.2.6.gem (100%)
Building native extensions. This could take a while…
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6…

Enclosing class/module ‘mMysql2’ for class Client not known

Enclosing class/module ‘mMysql2’ for class Result not known
Installing RDoc documentation for mysql2-0.2.6…

Enclosing class/module ‘mMysql2’ for class Client not known

Enclosing class/module ‘mMysql2’ for class Result not known
daniels-macbook:rails_mysql daniel$ rake db:migrate
(in /Users/daniel/Sites/rails_mysql)
rake aborted!
Please install the mysql2 adapter: gem install activerecord-mysql2- adapter (no such file to load – active_record/connection_adapters/
mysql2_adapter)

(See full trace by running task with --trace)
daniels-macbook:rails_mysql daniel$ gem install activerecord-mysql2-
adapter
ERROR: Could not find a valid gem ‘activerecord-mysql2-adapter’ (>=
0) in any repository
ERROR: Possible alternatives: activerecord-jdbch2-adapter,
activerecord-jdbcmysql-adapter, activerecord-postgis-adapter,
activerecord-jdbcmssql-adapter, activerecord-nulldb-adapter

$ gem install activerecord-mysql2-adapter
ERROR: Could not find a valid gem ‘activerecord-mysql2-adapter’ (>=
0) in any repository
ERROR: Possible alternatives: activerecord-jdbch2-adapter,
activerecord-jdbcmysql-adapter, activerecord-postgis-adapter,
activerecord-jdbcmssql-adapter, activerecord-nulldb-adapter


When i google the error Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (no such file to load –
active_record/connection_adapters/mysql2_adapter) people say: ‘try the
mysql2 gem’ i don’t understand why it has to be so difficult getting
rails 3 to work with mysql… it looks like a lot of people having
trouble to make it work.

Any ideas?

Thank you very much!

Nicholas writes:

C:\nuhype>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”’
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
Successfully installed mysql2-0.2.7
1 gem installed
Installing ri documentation for mysql2-0.2.7…
Enclosing class/module ‘mMysql2’ for class Client not known
Installing RDoc documentation for mysql2-0.2.7…
Enclosing class/module ‘mMysql2’ for class Client not known

C:\nuhype>rake db:migrate
(in C:/nuhype)
rake aborted!
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (no
such file to load – active_record/connection_adapters/mysql2_adapter)
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/connection
_adapters/abstract/connection_specification.rb:71:in rescue in establish_connec tion' C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/connection _adapters/abstract/connection_specification.rb:68:inestablish_connection’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/connection
_adapters/abstract/connection_specification.rb:60:in
establish_connection' C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/connection _adapters/abstract/connection_specification.rb:55:inestablish_connection’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/railtie.rb
:59:in block (2 levels) in <class:Railtie>' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_loa d_hooks.rb:36:ininstance_eval’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_loa
d_hooks.rb:36:in execute_hook' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_loa d_hooks.rb:43:inblock in run_load_hooks’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_loa
d_hooks.rb:42:in each' C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_loa d_hooks.rb:42:inrun_load_hooks’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/base.rb:19
03:in <top (required)>' C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/migration. rb:486:ininitialize’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/migration.
rb:433:in new' C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/migration. rb:433:inup’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/migration.
rb:415:in migrate' C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.6/lib/active_record/railties/d atabases.rake:142:inblock (2 levels) in <top (required)>’
C:/Ruby/lib/ruby/1.9.1/rake.rb:634:in call' C:/Ruby/lib/ruby/1.9.1/rake.rb:634:inblock in execute’
C:/Ruby/lib/ruby/1.9.1/rake.rb:629:in each' C:/Ruby/lib/ruby/1.9.1/rake.rb:629:inexecute’
C:/Ruby/lib/ruby/1.9.1/rake.rb:595:in block in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize’
C:/Ruby/lib/ruby/1.9.1/rake.rb:588:in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/rake.rb:581:ininvoke’
C:/Ruby/lib/ruby/1.9.1/rake.rb:2041:in invoke_task' C:/Ruby/lib/ruby/1.9.1/rake.rb:2019:inblock (2 levels) in top_level’
C:/Ruby/lib/ruby/1.9.1/rake.rb:2019:in each' C:/Ruby/lib/ruby/1.9.1/rake.rb:2019:inblock in top_level’
C:/Ruby/lib/ruby/1.9.1/rake.rb:2058:in standard_exception_handling' C:/Ruby/lib/ruby/1.9.1/rake.rb:2013:intop_level’
C:/Ruby/lib/ruby/1.9.1/rake.rb:1992:in run' C:/Ruby/bin/rake:31:in

Please someone help with this issue? gem install
activerecord-mysql2-adapter
does not exist? Please help fix the mysql and rails connection.

On Thu, Apr 21, 2011 at 3:25 PM, Nicholas
[email protected]wrote:

1 gem installed
such file to load – active_record/connection_adapters/mysql2_adapter)
_adapters/abstract/connection_specification.rb:60:in `establish_connection’
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_loa

rb:433:in up' C:/Ruby/lib/ruby/1.9.1/rake.rb:595:inblock in invoke_with_call_chain’
C:/Ruby/bin/rake:31:in `’

Please someone help with this issue? gem install
activerecord-mysql2-adapter
does not exist? Please help fix the mysql and rails connection.

I am not sure if this will help but I went through some trouble getting
mysql to play nice on my macbook upgraded to snow leopard. I found that
I
had to use mysql under 64 bit. I wrote a short blog post to remind
myself
how I resolved it. I am not sure if you are saying that you must run the
32
bit version , but if you are just happy to get mysql working you should
be
able to follow these steps:

http://blog.structuralartistry.com/post/4417260824/getting-mysql-and-mysql-gem-to-install-and-give-love-on

Nicholas wrote in post #994403:

Nicholas writes:

Please someone help with this issue? gem install
activerecord-mysql2-adapter
does not exist? Please help fix the mysql and rails connection.

I just ran into this same error message and I figured out what was going
wrong. If you try and load the rails console (rails c) you will probably
see the following warnings.

WARNING: This version of mysql2 (0.3.2) doesn’t ship with the
ActiveRecord adapter bundled anymore as it’s now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails
<= 3.0.x

When I ran “bundle install” it must have updated my mysql2 gem, which is
no longer compatible with rails 3.0. Not good.

I changed my Bundle file so the mysql 2 line looks like this:
gem ‘mysql2’, “0.2.7” # v0.3 requires rails 3.

Then run ‘bundle’ and everything should be good again.

Mike I am also a newbie. Where might I find this bundle file?

Sent from my iPhone

On May 16, 2011, at 1:33 PM, Rebecca D. [email protected] wrote:

Mike I am also a newbie. Where might I find this bundle file?

It’s called Gemfile and it’s in the root of your application folder.

B.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs