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.
Seems like your permissions aren't set right for root user or you have lost your MySQL root password.
I would try resetting MySQL password for root and trying again. I guess this is the fastest way. Follow these steps
step 1
Stop the mysql demon with this command
sudo /etc/init.d/mysql stop
step 2
Start the mysql demon process with following
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
(at this point it's safest to disable networking)
step 3
Start the mysql client with
mysql -u root
step 4
Then run following in mysql prompt, so you are able to change any password
FLUSH PRIVILEGES;
step 5
Then reset password with
SET PASSWORD FOR root@'localhost' = PASSWORD('password');
step 6
In case you happen to have a mysql root account that can connect from everywhere, this is recommended
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
step 7
Once you receive a message indicating a succesful query, then run
FLUSH PRIVILEGES;
step 8
Stop mysql and relaunch it with
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
I suppose you have these installed
web server apache
php
php_mysql support for apache
source: https://help.ubuntu.com/community/MysqlPasswordReset
Best Answer
I know this post is old, but here is what happened to me. I was upgrading and the phpmyadmin installer asked what the phpmyadmin user password should be, or to leave it blank to random generate a password. I hit enter without entering any password by mistake. So when I launched PHPMyAdmin, I got the error "mysqli_real_connect(): (HY000/1045): Access denied for user 'phpmyadmin'@'localhost' (using password: YES)".
To fix it, I found the "config-db.php" file in /etc/phpmyadmin/ and got the password from there. Root access to PHPMyAdmin was working, so I logged in as root to PHPMyAdmin and used the query "SET PASSWORD FOR 'phpmyadmin'@'localhost' = PASSWORD([copy and paste the password here])" and it worked!