mysql - Access denied for user 'user'@'localhost' (using password: NO) 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 &amp;
[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
owners.

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

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

mysql&gt; FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; exit
Bye

$ rake db:create
Access denied for user 'root'@'localhost' (using password: NO)Please provide the root password for your mysql installation
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).

Rails

In your database.yml file, you should have:

adapter: mysql
database: my_db
hostname: 127.0.0.1
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?