MySQL SQLSTATE[28000] [1045] (Magento) 用户访问被拒绝..(但新的 PDO,在测试程序中工作)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9651855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 12:28:06  来源:igfitidea点击:

SQLSTATE[28000] [1045] (Magento) Access denied for user .. (but new PDO, works in test program)

mysqlmagentopdo

提问by Francois99

I copied a Magento store to another provider and installed the database. Nothing special.

我将 Magento 商店复制到另一个提供商并安装了数据库。没什么特别的。

With testing always this error for the mysql database:

总是测试 mysql 数据库的这个错误:

SQLSTATE[28000] [1045] Access denied for user ‘xx'@'localhost' (using password: YES)

I found this program /httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.phpand has this statement:

我找到了这个程序/httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php并有以下声明:

try { 
    $this->_connection = new PDO( 
    $dsn, 
    $this->_config['username'], 
    $this->_config['password'], 
    $this->_config['driver_options'] 
); 

If I use the same statement with the same settings in a short test program on the same server, the connection works.

如果我在同一台服务器上的简短测试程序中使用具有相同设置的相同语句,则连接有效。

How is this possible? Is there something in PDO different working while called in Magento?

这怎么可能?在 Magento 中调用时 PDO 中是​​否有不同的工作?

I forgot to write, this domain has only a shared IP address and a domain name (but no DNS yet), so I coupled this IP address to this domain name in windows hosts file. So domain www.xxxx.com exists on the internet already, I use xxxx.com in windows host file coupled to the shared IP address. In this way I tested always new websites without an transferred domain yet.

忘记写了,这个域只有一个共享IP地址和一个域名(但还没有DNS),所以我在windows hosts文件中将此IP地址与该域名耦合。所以域名www.xxxx.com已经存在于互联网上,我在windows主机文件中使用xxxx.com与共享IP地址耦合。通过这种方式,我测试了始终没有转移域的新网站。

When I copy everything to my own server (localhost.com for Magento), I have to find it, all works well. So it has something to do with the situation at my provider ... but why it is working in my own test program for PDO with the same settings ?

当我将所有内容复制到我自己的服务器(Magento 的 localhost.com)时,我必须找到它,一切正常。所以它与我的供应商的情况有关......但为什么它在我自己的 PDO 测试程序中使用相同的设置工作?

$dsn = mysql:model=mysql4;initStatements=SET NAMES utf8;type=pdo_mysql;host=localhost;dbname=xxxx;active=1

$dsn = mysql:model=mysql4;initStatements=SET NAMES utf8;type=pdo_mysql;host=localhost;dbname=xxxx;active=1

回答by O?uz ?elikdemir

did you try :

你试过了吗 :

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

or

或者

GRANT ALL PRIVILEGES ON your_database.* TO 'user_name'@'localhost' IDENTIFIED BY 'your_password' WITH GRANT OPTION;

if you specified a BIND ADDRESS in my.cnf file which is an IP address, you should use IP address instead of localhost

如果你在 my.cnf 文件中指定了一个 BIND ADDRESS 是一个 IP 地址,你应该使用 IP 地址而不是 localhost

回答by Francois99

Thanks for all the answers, but the solution was simple.

感谢所有的答案,但解决方案很简单。

In the website of the previous provider was the password correct in local.xml

在以前的提供商的网站中,local.xml 中的密码是正确的

But the password given to me per email was wrong but impossible to see (little letter L and capital letter i, so that is l and I). So I mixed these passwords.

但是每封电子邮件给我的密码是错误的,但无法看到(小字母 L 和大写字母 i,所以是 l 和 I)。所以我混合了这些密码。

Lesson: check many times ...

教训:多次检查...