0

I want to configure mysql instead of Sqlite3. I had already configured the database.yml file:

development:
  adapter: mysql
  database: test
 username:false
 password:neha
 host :localhost
 port:3306

and also installed the mysql gem using gem install mysql

still i stuck out in error...please help me out :\rails\TestApp1>ruby script/server

Booting WEBrick Rails 2.3.11 application starting on http://0.0.0.0:3000 :/Ruby192/lib/ruby/1.9.1/syck.rb:135:in load': syntax error on line 13, col 0:test:' (ArgumentError) from C:/Ruby192/lib/ruby/1.9.1/syck.rb:135:in load' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:926:indatabase_configuration' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:437:in initialize_database' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:141:inprocess' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:113:in run' from C:/rails/TestApp1/config/environment.rb:9:in' from :29:in require' from <internal:lib/rubygems/custom_require>:29:inrequire' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:182:in block in require' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:547:innew_constants_in' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:182:in require' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/commands/server.rb:84:in' from :29:in require' from <internal:lib/rubygems/custom_require>:29:inrequire' from script/server:3:in `' i got this error

@d11wtq:
here is my yml file for mysql configuration:

ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "neha",
:database => "ruby"
)
& where i have to put
require 'mysql'

0

4 Answers 4

1

Looking at that log output you've now posted, it looks like you have haven't formatted that .yml file correctly. The use of whitespace in YAML is absolutely critical. Indent with spaces, not tabs, and make sure your indentation is consistent within each level. It appears that the lines are all aligned differently in your file, which is causing syck (the YAML parser) to throw an Exception.

EDIT | You also want to make the spacing between the key, the semi-colon and the value consistent too. Take pride in the layout of your code and you'll enjoy coding more ;) But pride or not... YAML is (intentionally) picky about whitespace.

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

Comments

1

Have your yml files properly indented and you will not be getting syntax error anymore. Also add mysql2 compatible version in your Gemfile, so that while you will be deploying it to any server it will take from Gemfile automatically.

Comments

0

Did you add "mysql" to your Gemfile and run "bundle install"?

1 Comment

hey can anyone send me the any article reagarding the configuration of mysql in ruby on rails.
0

If you're working on Windows, I know that I didn't have the MySQL C Driver installed on my machine. It's a different download than the MySQL Community Server. You also have to make sure that your PATH has the route to the C driver. Download the driver here.

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.