zend框架的奇怪错误
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
在 config.ini 中
[常规] db.适配器= PDO_MYSQL db.config.host = xxxhost db.config.用户名 = 用户名 db.config.password = 密码 db.config.dbname = dbname
acl.roles.user = null acl.roles.admin =
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);
用户我们非常准确地提供了所有凭据,但是,每当我们尝试访问数据库 [loginAction] 时,我们都会收到上述错误。此外,包含数据库操作的操作显示错误......在本地主机中它工作正常......
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....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这绝对是一个身份验证问题:
各种谷歌结果,SQLSTATE[28000] [1045],都指向身份验证错误。
您可以尝试这样做,liveaide_dbuser1'@'localhost 而不是 liveaide_dbuser1'@'lynx-u.znetindia.net - 也许存在一些问题..但前提是数据库服务器位于 Web 服务器上。
您确定您的身份验证凭据正确吗?
编辑:
好的,而不是这样做:
你能做到吗:
这样我们就可以确定传入的值是正确的吗? (用我的例子代替实际的正确论点)。
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:
Can you do:
So we can be sure the correct values are getting passed in? (Substitute my examples for the actual correct arguments).
如果您使用的是
Zend_Db_Adapter_Pdo_Mysql
适配器,则应该使用 PDO 进行测试。使用纯 ext/mysql API 进行测试并不是进行同类比较。(当然,填写您的密码代替 XXXX)在
运行 Zend Framework 应用程序的同一主机上运行此测试 PHP 脚本。这很重要,因为从一台主机连接时相同的用户名可能有效,而从另一台主机连接时则无效。如果您通过指定主机名调用 IP,则用户名甚至可能被授权通过环回方法(即“localhost”)进行连接,但不能从同一主机进行连接。
如果该段落对您来说没有意义,请阅读MySQL 访问特权系统直到它有意义。
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.(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.