Access denied for user 'root'@'localhost' (using password: YES) EVEN when the Password works on PhpMyAdmin

4.8k views Asked by At

I have an issue with accessing MySQL using root and password. I am trying to connect the Server using PuTTY SSH using

> mysql u root -p

For an unknown reason I can NOT access the Database and I am getting rejected with the following ERROR:

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

The weird thing is that I am using the same password with PhpMyAdmin using Web and I can access everything. I need to run a script that will allow the SQL server

root@localhost user

run the query over the LAN and not the web.

Therefore I need the user to connect using command line SSH or something like that.

How can I fix that issue? the user rott and password WORKS just fine through PhpMyAdmin and not through SSH PuTTY, Why?

Is there something I need to do in order to fix this? I have been working with the Database for 2 years now using the web interface. Now I need to have it working using SSH (22).

Please assist. thanks in advance. Arye

4

There are 4 answers

13
Grant P On

It sounds like you need to update the your password for root on MySQL. Check here: MySQL - ERROR 1045 - Access denied

0
Atul Baldaniya On
> mysql -h your_host_name -P your_port_number -u your_user_name -p

try with hostname option it should work!

0
mobby On

Ubuntu 18.04 running MySQL 5.7.28 creates a file /etc/mysql/debian.cnf. It contains some credentials and other settings. So, this debian-sys-maint user is by default a root equivalent. It is used by certain maintenance scripts on Debian systems, and as a side-effect, allows users with root access on the box to view the plaintext password in /etc/mysql/debian.cnf. If your SSH using a client fails after a fresh install through root try using the credentials set in this file.

0
Arye Guetta On

Thank you all for your help. I have managed to overcome the issue: (see below)

That was FIXED Only when I changed from old password to new. in my.cnf file I have removed the flag for old_password=1 and Restart the service of MySQL.

Then I have created a NEW password (using the old one I had) and it was created with 41 (NEW) Hash length and not 16 (OLD)..

Then I did flush privileges as you recommended - and IT WORKS. Thank You!