Ubuntu – MySQL Access denied for user ‘root’@’localhost’

12.04MySQLpasswordserver

In my server, everytime I try to access MySQL I get the error:

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

when I try mysqladmin -u root -p password I get

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

How can I access MySQL in my Ubuntu server 12.04?

Best Answer

If you're running n localhost, just type the command below in terminal:

mysql -u root -p

If you're using an external server, enter the host IP (xxx.xxx.xxx.xxx) as well:

mysql -hxxx.xxx.xxx.xxx -uroot -p

You will be prompted for your password, enter it and you will be able to access your MySQL prompt.

You can also look at this answer on how to reset your MySQL password.