views:

278

answers:

2
Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[28000] [1045] Access denied for user 'liveaide_dbuser1'@'lynx-u.znetindia.net' (using password: YES)' in /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Pdo/Abstract.php:144 Stack trace: #0 /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Abstract.php(447): Zend_Db_Adapter_Pdo_Mysql->_connect() #2 /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Pdo/Abstract.php(235): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Select), Array) #3 /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Abstract.php(705): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Select), Array) #4 /home/liveaide/public_html/aider20test/zyberops/application/modules/default/models/Users.php(33): Zend_Db_Adapter_Abstract->fetchAll(Object(Zend_Db_Sel in /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144

in config.ini

[general] db.adapter = PDO_MYSQL db.config.host = xxxhost db.config.username = username db.config.password = password db.config.dbname = dbname

acl.roles.user = null acl.roles.admin = user

in index.php

$config     = new Zend_Config_Ini('./application/config.ini','general');
$registry   = Zend_Registry::getInstance();
Zend_Registry::set('config',$config);

$db         = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db',$db);

we provided all the credentials very accurately but , whenever we try to access the database [loginAction] we got the above error . Also the action containg database operations displays the error .... In localhost it works fine....

+4  A: 

Its definitely an authentication problem:

Various google results for, SQLSTATE[28000] [1045], all point to auth errors. You might try doing, liveaide_dbuser1'@'localhost instead of liveaide_dbuser1'@'lynx-u.znetindia.net - Maybe there's some problems .. but only if the DB server is on the web server.

Are you sure you have the authentication credentials correct?

Edit: Ok, instead of doing:

$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());

Can you do:

$db = Zend_Db::factory('pdo', array('user'=>'MyDbUser', 'pass' => 'MyPassword', etc);

So we can be sure the correct values are getting passed in? (Substitute my examples for the actual correct arguments).

Mr-sk
yes im sure it is correct. becoz we checked with normal php database connection. it works fine there....
Nisanth
we checked with normal php database connection- You mean non using pdo? How did you check?
Mr-sk
Make sure the user has the proper permissions for the database. Seems to be a step I always forget.
Eric Coleman
<?php$host = 'xxxhost';$db = 'testdb';$user = 'testuser';$passwd = 'test pass';$con = mysql_connect($host,$user,$passwd);if($con){ $sel_db = mysql_select_db($db,$con); if($sel_db) { echo "Database connection success"; $sql = "select * from users"; $res = mysql_query($sql); while ($row = mysql_fetch_array($res)) { echo $row['user_id']; } } else { echo "cant select databse"; } }else echo "cannot connect databse";like above code it works and we got answer
Nisanth
@Mr-sk THANK U VERY MUCH , UR SUGGESTION IS CORRECT WE GOT IT....
Nisanth
A: 

You should test with PDO if you are using the Zend_Db_Adapter_Pdo_Mysql adapter. Testing with the plain ext/mysql API is not comparing apples to apples.

<?php
$pdo = new PDO("mysql:host=lynx-u.znetindia.net;dbname=test", 
    "liveaide_dbuser1", "XXXX");
echo "Test successful"; // no exception thrown
?>

(of course fill in your password in place of XXXX)

Run this test PHP script on the same host you run your Zend Framework application. This is important, because the same username may work when connecting from one host and not from another host. The username may even be authorized to connect via a loopback method (i.e. "localhost") but not from the same host if you invoke IP by specifying the hostname.

If that paragraph made no sense to you, read about The MySQL Access Privilege System until it makes sense.

Bill Karwin