1

When I type rails server in my CMD the server works and I can go to localhost:3000. But after i get this messege in the CMD and the same message in the browser on localhost:3000 in the errors section.

Started GET "/rails/info/properties" for 127.0.0.1 at 2010-12-02 21:14:55 +0200

Mysql2::Error (Access denied for user 'root'@'localhost' (using password: NO)):

Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_dispatc
h/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_dispatc
h/middleware/templates/rescues/_request_and_response.erb (30.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_dispatc
h/middleware/templates/rescues/diagnostics.erb within rescues/layout (97.0ms)

What is the issue?

here this is the database.yml file:

# MySQL. Versions 4.1 and 5.0 are recommended. # # Install the MySQL driver: # gem install mysql2 # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql2 encoding: utf8 reconnect: false database: simple_cms_development pool: 5 username: root password: host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run

"rake". # Do not set this db to the same as development or production. test: adapter: mysql2 encoding: utf8 reconnect: false database: simple_cms_test pool: 5 username: root password: host: localhost

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_production
  pool: 5
  username: root
  password:passwordex
  host: localhost
2
  • Your MySQL DB server isn't allowing access by root. What users are configured for MySQL? Commented Dec 2, 2010 at 19:31
  • i think everyone.. the defuelt, how can i change this? Commented Dec 2, 2010 at 19:39

2 Answers 2

3

I know you already found the solution to your problem, but I'm going to post this as an answer anyways, for those who might stumble across this same issue.

Having the same exact Access denied for user 'user'@'localhost' (using password: NO) problem, it turns out my database.yml file was malformatted. The reason? YAML doesn't allow certain characters: I happened to be using a '!' in my password, and for whatever reason, the YAML parser reading this database.yml file ignored my password line like it wasn't there, hence the (using password: NO), even though I explicitly declared it.

Solution? Changed my password not to include any YAML special characters. I suppose there might be a way to escape it, though. Annoying nonetheless.

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

1 Comment

You can also wrap it in quotes.
1

You're using root for your mysql user, but not supplying the root password in config/database.yml.

Incidentally, while its usually ok in development, using the root mysql user in production or for staging is a Very Bad Idea™.

here's a typical mysql config section:

production:
  adapter: mysql
  database: app_production
  username: root
  password: password
  pool: 5
  timeout: 5000
  encoding: utf8

8 Comments

10x!!! so what i shoud write here="password:" in the file config/database.yml ? i wrote just the password for exmpale: "pass1234" like this: password: pass1234 , and it telling me the syntix is worng whats worng? 10x agin man!
ArgumentError syntax error on line 38, col 1: ` password123 host: localhost'
You'll have to paste your database.yml file. Please edit your question to include that so that formatting is preserved.
you need a space after "password:" => "password: password"
Also, make sure you're running the environment you expect to be running. if you just run "script/server" or "rails server" you're going to be in the development environment, not production, so make sure you set the database password there.
|

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.