I just installed MySQL 5.5 and right after install I was asked to set root password by executing those two commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h linux-opxd password 'new-password'
or
/usr/bin/mysql_secure_installation
I executed first command -- OK. I executed second command this time with error:
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
I re-executed the first one (for checking) -- error as above.
So, I executed mysql_secure_installation
. Everything went fine and my password was recognized. So I executed the first two commands again -- and error again.
As another check:
mysql --user=root
The same error as above.
I tried resetting the password with mysql authentication, also I tried /usr/bin/mysql_upgrade -u root -p
-- still the error while trying to launch mysql console as root.
So finally I turned authentication off, connected to console and executed this:
SELECT user();
The output -- root@
. If I connect like this:
mysql --user='root@localhost'
I will get root@localhost@
.
So for now it seems it is not the problem with privileges, or lack of password or anything like this, but no recognizing the user which was given at command line -- mysql appends @
at the end and this seems to be the problem (at least for my eye).
The question is: how to make MySQL recognize the given user?