0

I'm very new to rails and am trying to familiarize myself with the framework by following the Rails Essential Training on Lynda.com. Although I thought that I got everything installed properly, I am running into some trouble when trying to launch a WEBrick server. The problem seems to be with mySQL, because I get an error right after it exits on me and I have no idea what it's trying to tell me. If someone could have a look at the error and recommend any possible solutions it would be very much appreciated!!

I am running:
OSX Mountain Lion
Ruby 2.0
Rails 3.2.13
mysql Ver 14.14 Distrib 5.6.10, for osx10.8

    adamcord$ rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Unknown database 'simple_cms_development' (Mysql2::Error)
    from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `send'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `checkout'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `checkout'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `connection'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `send'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config/environment.rb:5
    from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:3:in `require'
    from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:3
    from /Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:0:in `new'
    from /Users/adamcord/Desktop/Course Work/Lynda.com Exercises/Sites/simple_cms/config.ru:0

I have tried using the rake db:create command but that seems to open up a whole new bag of issues.

  • When installing mysql make sure you create a user(not root) with a password that has all privilege. Then when creating your rails app add the user and database to your database config file. See if that works. I once had this problem. – coletrain May 01 '13 at 04:42
  • How do I create a user? I believe I only have a root user. –  May 01 '13 at 14:53

1 Answers1

0

The database you are trying to connect to doesn't exist:

Unknown database 'simple_cms_development'

Can you check if it in fact exists and if your settings in config/database.yml are correct ? That may be also the reason why rake db:create also fails (would be useful to paste the errors that you get from it).

ılǝ
  • 3,440
  • 2
  • 33
  • 47
  • `rake db:create` could fix this. – tadman May 01 '13 at 04:32
  • Ah, there it is at the bottom of that giant stack trace. Right you are. – tadman May 01 '13 at 04:53
  • Yes, I figured that was the issue. To be honest I don't know if the settings are correct. In my config/database.yml there is definitely a database in there that says `simple_cms_development` and I have not done anything to change it. As for the errors, I get `Could not find arel-3.0.2 in any of the sources Run 'bundle install' to install missing gems.` I've run bundle a bunch of times, but I checked my gem list and it says that I have arel 4.0.0 installed. –  May 01 '13 at 14:39
  • Right now I am installing all of the compatible versions of my gems just so I can get rake to work... Is there an easier way??? –  May 01 '13 at 14:57
  • 1 Database connection: Here are some examples how development.yml can look like: https://gist.github.com/erichurst/961978 You can also specify "host: x.x.x.x" (or localhost) among other settings. The settings are specific, you need to figure it out on your own depending on your setup. 2 Inspecting the database: I suggest using a program, my best choice is MySQL Workbench 3 Bundle problems: You have different arel version. Open your Gemfile (in your IDE or any text editor) and change the version requirement to 4.0.0) The focus of the question has shifted, please consider accepting the answer. – ılǝ May 02 '13 at 02:01
  • finally got everything sorted. Had to update all my gems manually and then create a db with rake, then start with `rails s`. Thank you for responding. –  May 02 '13 at 21:11