Jump to content

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


Rudolfmdlt

Recommended Posts

Hi There,

 

I am a voice engineer, not a php programmer or mysql specialist. I employ a tool written in php to assist in the mass provisioning of phones. This tool has now broken and I would appreciated help in debugging the situation. I have experience in Java, C++ and MySQL but I am finding it incredibly frustrating not to be able to step through the PHP code and track the variables, their values, and ultimately find where the problem is. Any help will greatly be appreciated.

 

MySQL version: Server version: 5.1.67

 

Error from the SQL error log: Access denied for user 'root'@'localhost' (using password: YES)

 

Code PHP where I set the MySQL username and password:

 

<?php
include_once(dirname(__FILE__)."/ez_sql_core.php");
include_once(dirname(__FILE__)."/ez_sql_mysql.php");

class mysqldbaccess
{
var $db;
var $freepbxdb;

function mysqldbaccess()
{
//database settings
$username="root";
$password="";
$name="snom";
$host="localhost";
$this->db=new ezSQL_mysql($username,$password,$name,$host);
}

function freepbxdbaccess()
{
//echo "hi";
//database settings
$username="root";
$password="";
$name="asterisk";
$host="localhost";
$this->freepbxdb=new ezSQL_mysql($username,$password,$name,$host);
}

 

Now in your forum Sticky you say you don't want php code, but the raw sql query - It seems this tool employs a library called EZ_SQL - and I trust that the library query is fine? How can I track whether the username and password I supply are passed to MySQL correctly? Can I see the username and password presented to MySQL? (The password is intentionally blank in the forum post)

 

Now from my research my error is because:

1) I'm not supplying the correct password. As a above, I know I typed the values in correctly, whether they actually get to sql is another questions. I have used this tool many times before so I doubt this is the issue.

 

2) Permissions and Privileges on my database. The correct username and password does not guarantee access to all DB's?

 

show grants for root;
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@% |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*Half the hash removed on purpose CBEB70167D0D3D1F4' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `snom`.* TO 'root'@'%' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

 

 

 

mysql> show grants for root@localhost;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*Half the hash removed on purpose C316CBEB70167D0D3D1F4' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `snom`.* TO 'root'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

 

 

The server is running Centos 6.3, I get the connection refused error when I try to log in remotely or on they local machine with lynx.

 

I would really appreciate any advise on debugging this issue.

 

Kind Regards,

 

Rudolf

Edited by Rudolfmdlt
Link to comment
Share on other sites

There are at least two IDEs that I know of which has proper debuggers for PHP, Zend Studio and Eclipse (With xdebug). You might want to give them a look, if you want to properly debug your scripts in the future. :)

 

That said, it sounds like your SQL connection details aren't set (properly) on the MySQL server. Seeing as the PHP script is indeed trying to use a password. So, just to be on the safe side: You have verified that you can manually log in to the MySQL server with those details? Also, did you remember to flush the privileges if the password has been changed recently?

If nothing of the above helped, then the problem is (most likely) in the PHP code. Specifically the constructor for the ezSQL_mysql class. In that case, we'll have to see the PHP code for it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.