0

I'm using the Lynda.com tutorial to learn Ruby on Rails. In Chapter 6, they go through creating a mysql database and then configuring it for Rails. After we create and configure the database, the instructor tests the connection with this command from the root of our rails application

rake db:schema:dump

which created a schema.rb file in the "db" folder of the rails application.

However, for me, I got this error message when I ran the rake command

rake aborted!
syntax error on line 18, col 2: `  socket: /tmp/mysql.sock'

Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)

I tried to do --trace to check the error but it didn't do anything.

My database.yml file (where we configured the database for rails) is the same as the instructors, except his uses mysql and mine says mysql2 for the adapter attribute

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_development
  pool: 5
  username: simple_cms
  password: secretpassword
  socket: /tmp/mysql.sock              <<---this is line 18 as referred to in error 

Anyways, the error message said syntax error in line 18, but my line 18 is exactly the same as the instructors...

Any ideas how I can fix this problem?

UPDATE -- this command rake db:schema:dump --trace gave me this output

** Invoke db:schema:dump (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
syntax error on line 18, col 2: `  socket: /tmp/mysql.sock'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.1.0/lib/rails/application/configuration.rb:100:in `database_configuration'
/Library/Ruby/Gems/1.8/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:6
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:205:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:176:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:62:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/bin/rake:32
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Tasks: TOP => db:schema:dump => db:load_config
5
  • If you are using windows you don't need the socket parameter. Otherwise, try removing that line altogether. Commented Sep 15, 2011 at 2:02
  • You should try "rake db:schema:dump --trace" to get the backtrace. You should also try using the mysql (not mysql2) gem so that you are running with the same setup as the instructor. Commented Sep 15, 2011 at 2:04
  • @sosborn I followed the exact same installation instructions as instructor. think he had mysql2 gem as well...anyways, i did the backtrace and put it in an update in the OP. does it tell you anything? Commented Sep 15, 2011 at 2:10
  • @Ingenu I tried it without that line but then it got error messages later in file Commented Sep 15, 2011 at 2:12
  • 1
    The error above says that the yaml is not correct. Make sure you are using consistently using only spaces or only indents. Commented Sep 15, 2011 at 2:21

2 Answers 2

1

I had the same issue today. In your database.yaml file, make sure you have a space between the key: and value. For instance,

database: simple_cms_development

password: dfdjfdfd

Make sure you have a BLANK SPACE between : and your value.

Sign up to request clarification or add additional context in comments.

Comments

1

new rails version write in routes.rb file top

Blog::Application.routes.draw do

  get "demo/index"

don't put |map|

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.