ERROR 1045(28000) : Access denied for user 'root@localhost' (using password: no )

Add switch -p for password based login:

mysql -u root -p

That is the normal behaviour. You set a root password for your database so from now on you can't access it without password. That is why it reports:

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

Obviously when you give the password with the -p switch you succeed.


In simple words your "root" session do not know password to mysql root user.

If you want to make easier to access your mysql

create .my.cnf in /root/

and put in it

[mysqladmin]
 user = root
 password = mysqlrootpassword
[mysql]
 user = root
 password = mysqlrootpassword
[mysqldump]
 user = root
 password = mysqlrootpassword

where offcourse mysqlrootpassword is your password for mysql's root password so when you execute mysql it uses this password

Remeber about safety of this file - put secure rights, so nobody on your server can read it!