0

I'm totally new to programming, and I've started my training by watching the ruby on rails 4 essential training tutorial at lynda.com. I got to the section where I was supposed to create a web server by first opening the code in my database.yml file, then entering my password for mysql, then starting a server by typing "rails server" in the command line. It didn't work at localhost:3000. I tried granting privileges to the databases in mysql to the account, and I even tried changing the password, but it still doesn't work. When I go to localhost:3000, it still says : Access denied for user 'root'@'localhost' (using password: NO).

Also, I have a host name written in the code, but no socket. I don't know if this changes anything, I may just have a newer version of mysql than the guy in the video.

Here is the code:

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem '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
  database: #my_cms_development
  pool: 5
  username: root
  password: snapple187
  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
  database: my_cms_test
  pool: 5
  username: root
  password: snapple187  
  host: localhost

production:
  adapter: mysql2
  encoding: utf8
  database: #my_cms_production
  pool: 5
  username: root
  password: snapple187 
  host: localhost

Thank you for taking the time to help solve this issue.

  • This belongs on Database Administrators – Jim Garrison Jan 19 '14 at 0:15
  • 1
    Is there a reason for a '#' in front of the database under 'development' section? – andHapp Jan 19 '14 at 1:06
  • @andHapp I was just a little confused at the time with the tutorial I was taking. I now know that since I was in the development environment, I didn't need to comment it out, even though the database was nonexistent. – user3211059 Jan 22 '14 at 16:46
  • @jimgarrison Don't worry, it's in the database.yml file. That's the right file for the course I'm taking. – user3211059 Jan 22 '14 at 16:48
1

This is how I have always set up my rails projects, using SQLite in your test and development will save you this heartache!

#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# 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: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: mysql2
  encoding: utf8
  database: #your db name
  username: #your db username
  password: #your db password
  host: #your db hostname
  port: 3306
  • why would sqlite3 save headaches compared to other environments? I'm asking because I'm also getting into RoR. – camdixon Jan 19 '14 at 3:03
  • 1
    @camdixon because it doesn't need credentials, or configuration, doesn't need starting, or stopping etc, it's just a simple database store for a single user type situation, which is perfect for a development environment on your single developer computer. – Aaron Jan 19 '14 at 3:09
  • @camdixon If you're new to programming like me, (and even if you're not), you should go to Lynda.com, and take the free week long trial. Complete the ROR 4 essential training course in that week for free. You may have to type "lynda free week trial", or something to that effect in google to find the trial. I couldn't find it by simply going to the site. IDK why. – user3211059 Jan 22 '14 at 16:44
0

SO...after I created the server in the command line, then got rid of it with ctrl + C, it cancelled the server, but left a file remaining. It said that the file "server.pid" already exists. But since the PATH didn't exist, I couldn't close it from the command line. All I had to do was click the "start" icon, then search programs and files for "server.pid". Delete that file, then delete it from your recycle bin.

Now everything should work fine when you start a new server.

P.S. it seems like such a simple fix now, but remember, I was brand spankin' new to this a few days ago. Thanks Guys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy