-1

I have spent the last 6 hours fixing issues like modifying the $PATH, installing Gems to finally get everything as it should be. but after I create the project folder with it's components and trying to run the server, I got this message :-

\KAMAL$ ls
Gemfile     README.rdoc app     config.ru   doc     log     script      tmp
Gemfile.lock    Rakefile    config      db      lib     public      test        vendor
\KAMAL$ rails server
=> 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': Access denied for user 'root'@'localhost' (using password: NO) (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'

"and many many lines as the same above"

the gem list * LOCAL GEMS *

actionmailer (3.2.13)
actionpack (3.2.13)
activemodel (3.2.13)
activerecord (3.2.13)
activeresource (3.2.13)
activesupport (3.2.13)
arel (3.0.2)
builder (3.0.4)
bundler (1.3.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.2)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.2)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.2.1)
json (1.7.7)
mail (2.5.3)
mime-types (1.22)
multi_json (1.7.2)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.13)
railties (3.2.13)
rake (10.0.4)
rdoc (3.12.2)
rubygems-update (2.0.3)
sass (3.2.7)
sass-rails (3.2.6)
sprockets (2.2.2)
thor (0.18.1)
tilt (1.3.7)
treetop (1.4.12)
tzinfo (0.3.37)
uglifier (2.0.1)
webrick (1.3.1) 

please help

pktangyue
  • 8,326
  • 9
  • 48
  • 71
  • 3
    What does your `config/database.yml` look like? Under `development` it seems you've specified `mysql` as the adapter, and `root` as the user. Look at the `database` name in that configuration, and verify with your MySQL client whether or not the root user can connect to that database. Also, why do you think this is WEBrick's fault? – Amit Kumar Gupta Apr 18 '13 at 03:24

1 Answers1

2

This log entry

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

Shows that you are using the user root at localhost without password as database. MySQL don't find this as a valid user. the following line should issue the same error message:

mysql -u root -h localhost

So check your database user/password in your db/database.yml file

fotanus
  • 19,618
  • 13
  • 77
  • 111
  • I have a password for mysql I connect to mysql via the terminal with the password and I did show the databases without a problem – Ahmed elhamahmy Apr 18 '13 at 14:48
  • whe do I find the db/database.yml file – Ahmed elhamahmy Apr 18 '13 at 14:51
  • @Ahmedelhamahmy the file is in `path/to/your/application/db/database.yml`. I strongly recommend you to follow the [ruby guides](http://guides.rubyonrails.org/) to understand better what you are doing. – fotanus Apr 18 '13 at 16:49
  • Why The Server starts and Ends directly and I canot access it on browser under localhost:3000 – Ahmed elhamahmy Apr 18 '13 at 17:21
  • @Ahmedelhamahmy because it can't access the database and you have models that extendes ActiveRecord::Base, so it is a pre-requisite to run. Sorry, I'll not answer your questions any longer, I stronlgy recommend you to take a Rails curse or something. – fotanus Apr 18 '13 at 18:06