0

Hi I am new to Ruby on Rails. I created a new project using Aptana Studio and started the server using rails server command. But when I'm trying to access the server via browser I'm getting the following error.

https://i.sstatic.net/7P0FE.png

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


      socket = socket.to_s unless socket.nil?

      connect user, pass, host, port, database, socket, flags
    end

def self.default_query_options

Rails.root: /home/tapas/RubyWorkspace/myproj

Application Trace | Framework Trace | Full Trace
mysql2 (0.3.18) lib/mysql2/client.rb:70:in `connect'
mysql2 (0.3.18) lib/mysql2/client.rb:70:in `initialize'
activerecord (4.2.1) lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
activerecord (4.2.1) lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/tapas/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/tapas/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
activerecord (4.2.1) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.2.1) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.2.1) lib/active_record/migration.rb:384:in `connection'
activerecord (4.2.1) lib/active_record/migration.rb:371:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'

I tried using all host:port combinations e.g. 3000,3306..etc ,but nothing works. And here's how my database.yml file looks like.

https://i.sstatic.net/a9ok1.png

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: mysql_dev
  pool:5
  username: root
  password: tapaskumar
  socket: /var/run/mysqld/mysqld.sock
  host: localhost
  port: 3306

test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: mysql_test
  pool: 5
  username: root
  password: tapaskumar
  socket: /var/run/mysqld/mysqld.sock
  host: localhost
  port: 3306

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: mysql2_prod
  pool: 5
  username: root
  password: tapaskumar
  socket: /var/run/mysqld/mysqld.sock
  host: localhost
  port: 3306

When I'm trying to access mysql from terminal, it works fine. Also I installed mysql using this command.

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

And also have the mysql gem installed for the project. I'm unable to figure out whats wrong.

3
  • 1
    Well, for starters it seems like your app is attempting to connect to the MySQL database without a password. Unfortunately I can't tell you why, but start by double checking your settings. Commented May 6, 2015 at 19:56
  • 1
    The title of the question could be more descriptive. Commented May 6, 2015 at 19:58
  • what's the command you use to login to your sql server from the command line? do you specify the user as "root" there as well? Commented May 6, 2015 at 21:55

1 Answer 1

1

I was editing some global database.yml file previously .Then i found out a specific database.yml file on config folder of the project directory ,which i think is specific to that project.After few indentation errors ,Finally got it.

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

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.