Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to fix the infamous "Access denied" error, but I don't understand why my fix doesn't work. Can someone please help me?

EDIT: This is the sequence of steps I took to fix the problem. It is still not working. Can anyone tell me what I'm doing wrong?

$ sudo service mysql stop
mysql stop/waiting
$ sudo service mysql start
mysql start/running, process 5718
$ sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
[1] 5758
$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 85
Server version: 5.5.32-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> UPDATE mysql.user SET Password=PASSWORD('test')
    -> WHERE User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4  Changed: 0  Warnings: 0

Query OK, 0 rows affected (0.00 sec)

mysql> exit

$ rake db:create
Access denied for user 'root'@'localhost' (using password: NO)Please provide the root password for your mysql installation
share|improve this question
Does the rake program supply the root password ('test') to mysql when it tries to create a database? You have changed the password in MySQL but I guess you haven't informed rake about it. – ypercubeᵀᴹ Oct 13 '13 at 8:05

This isn't a database problem at all. The tipoff is the "using password: NO" in the error message. Ensure that you're sending a password in your authentication as follows:

Command line

The correct syntax for the CLI client is:

$ mysql -uroot -ptest

Or you can just use -p (with no value), which will prompt you for a password. Note that there's no space between the flag (-u/-p) and the value (myuser/mypassword).


In your database.yml file, you should have:

adapter: mysql
database: my_db
username: root
password: test
socket: /tmp/mysql.sock
pool: 5
timeout: 5000

Running rake db:create should now properly create your database.

See: ruby – How do I set up the database.yml file in Rails?

share|improve this answer
Hi, can you please look at my edit? Thanks. – dtgee Oct 13 '13 at 5:32
After the edit, you're now asking a completely different question. I've updated my answer. – Mikkel Oct 13 '13 at 8:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.