DBI connect failed : Access denied for user 'root'@'localhost' to database 'mysql'

20 posts / 0 new
Last post
#1 Thu, 04/24/2014 - 00:59
aryan481

DBI connect failed : Access denied for user 'root'@'localhost' to database 'mysql'

I am getting error message like this :

DBI connect failed : Access denied for user 'root'@'localhost' to database 'mysql'

i am unable to add new VPS server or delete any Vps server .

unable to add new user or delete any thing everytime when i do this get error message like this.

DBI connect failed : Access denied for user 'root'@'localhost' to database 'mysql'

please help me what i done wrong ??

recently i restore backups !! from my backups.

thank you. aryan

Thu, 04/24/2014 - 09:44
andreychek

Howdy,

Try going into Webmin -> Servers -> MySQL -> Module Config, and there, set "Administration password" to your correct root MySQL password.

If that doesn't work -- did you perhaps change to a non-standard MySQL version recently, such as one from a third party repository?

-Eric

Thu, 04/24/2014 - 10:38
aryan481

tried but not worked ,

i have in my memory what is password , i didn't forget it so not required to change.

if i change in the method you just told it not getting login with new password , only works with my old mysql password .

error message still there

Thu, 04/24/2014 - 10:42
aryan481

my mysql password is correct and working fine in SSH and webmin mysql login but only getting this error.

unable to delete a server or create same error coming.

Thu, 04/24/2014 - 13:06
andreychek

Did you perhaps change to a non-standard MySQL version recently, such as one from a third party repository?

Also, what distro/version are you using?

-Eric

Fri, 04/25/2014 - 10:06 (Reply to #5)
aryan481

No, i didn't change mysql only i did , i migrate this current server to a new VPS server by backup this server and restore to new VPS ,

after that i delete this server ,

after someday i just restore data backup to this server from that backup data file , after that problem started .

any idea??

also a new problem with my new VPS i am not able to loging via FTP . error message is connection REFUSE !! i restore this server from my old one.

Thu, 04/24/2014 - 21:12
maznos

hello,

check if /root/.my.cnf exist, it might be the problem

Fri, 04/25/2014 - 10:02 (Reply to #7)
aryan481

its say No such files in directory

Fri, 04/25/2014 - 12:58
andreychek

What distro/version is it that you're using?

-Eric

Fri, 04/25/2014 - 13:21
aryan481

4.06.gpl centOS Linux 6.5

Fri, 04/25/2014 - 15:15
andreychek

Okay, and what is the output of this command:

rpm -qa | grep mysql

Fri, 04/25/2014 - 21:30 (Reply to #11)
aryan481

is is asking for password and when i put my mysql password : access denied !!

Sat, 04/26/2014 - 10:26 (Reply to #12)
Locutus

The command Eric asked you to execute has nothing to do with MySQL, it's a call to "rpm", the CentOS package manager. It should not ask you for a password, and you should not need the MySQL root password there!

Sat, 04/26/2014 - 10:53 (Reply to #13)
aryan481
Sat, 04/26/2014 - 23:51
andreychek

Howdy,

Okay, that MySQL version looks correct.

However, your previous comment makes me wonder... what happens if you run this command:

mysql -u root -p

And then enter your MySQL password -- does it allow you into MySQL?

If so, what happens if you then run this command within the MySQL shell:

use mysql

Do you receive any errors trying to run "use mysql"?

-Eric

Sat, 04/26/2014 - 23:51
andreychek

Howdy,

Okay, that MySQL version looks correct.

However, your previous comment makes me wonder... what happens if you run this command:

mysql -u root -p

And then enter your MySQL password -- does it allow you into MySQL?

If so, what happens if you then run this command within the MySQL shell:

use mysql

Do you receive any errors trying to run "use mysql"?

-Eric

Sun, 04/27/2014 - 00:07 (Reply to #16)
aryan481

i am able to access my mysql by using my password with this command mysql -u root -p

but when i try this command "use mysql" again same message display "ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql"

any idea ?

Thank You.

Sun, 03/27/2016 - 05:47
masterg0g0

SQL is having trouble to localhost not also setup in the DNS as 127.0.0.1 I am using proxmox virtual environment at the container level and i had to setup it there..

Sun, 06/12/2016 - 15:12
pawelkb
pawelkb's picture

Hi, I have got the same problem as above: The full MySQL error message was : DBI connect failed : Access denied for user 'root'@'localhost' (using password: NO). When I type rpm -qa | grep mysql I get php-mysql-5.4.16-36.1.el7_2.1.x86_64, than after mysql -u root -p I get Enter password: and after I enter password I get ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I have got centos-release-7-2.1511.el7.centos.2.10.x86_64. Any Idea?

Pawel

Thu, 06/16/2016 - 23:47
Abdul Rehman

Even i got the same error,

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


I am using Centos 6.8 Virtualmin 5.0.3 GPL.
I just changed the password of root going to Webmin ->System->Change Password (Change password for root and mysql)
after that i can able to login Webmin -> Server -> MySQL Database Server. Done.

Then go to Virtualmin -> System settings ->Features and Plugins. Select the MySQL database and Save.
If you are getting a following error

Failed to save enabled features : Virtualmin is configured to setup DNS zones, but this system is not setup to use itself as a DNS server. Either add 127.0.0.1 to the list of DNS servers, or turn off the BIND feature on the module config page.

Just go to
Hostname and DNS Client or https://your_hostname:10000/net/list_dns.cgi and add 127.0.0.1 in your DNS servers. Save -> Apply Configuration.

Now again go to Virtualmin -> System settings ->Features and Plugins. Select the MySQL database and Save.

Just restart the webmin under webmin configuration and re-check the configuration under Virtualmin -> System Settings.

This way it solved the dbi caonnect mysql problem for me, hope this will help newbie like me.