laravel [PDOException]- SQLSTATE[HY000] [1045] 用户“root”@“ip”的访问被拒绝(使用密码:YES)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28073934/
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
[PDOException]- SQLSTATE[HY000] [1045] Access denied for user 'root'@'ip' (using password: YES)
提问by omarsafwany
I am trying to connect to AWS through ssh in order to migrate some files. I connected successfully using the following command:
我正在尝试通过 ssh 连接到 AWS 以迁移一些文件。我使用以下命令成功连接:
ssh -i ~/Downloads/key.pem ec2-user@myuser
Then, I tried to run the following :
然后,我尝试运行以下命令:
php artisan migrate
I got the following:
我得到以下信息:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'user'@'ip' (using password: YES)
What could be preventing me from accessing my DB in order to migrate?!
什么可能阻止我访问我的数据库以进行迁移?!
回答by Alan Storm
When you connect to AWS you're connecting to a unix shell account on a virtualize linux server via SSH.
当您连接到 AWS 时,您将通过 SSH 连接到虚拟化 linux 服务器上的 unix shell 帐户。
On this virtual server (or maybe another server), you're running an instance of a database application. This database application is alsoa server. However, it has its own credential system. When you see this error message
在此虚拟服务器(或可能是另一台服务器)上,您正在运行数据库应用程序的实例。这个数据库应用程序也是一个服务器。但是,它有自己的凭证系统。当您看到此错误消息时
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'user'@'ip' (using password: YES)
[PDOException]
SQLSTATE[HY000] [1045] 用户 'user'@'ip' 访问被拒绝(使用密码:YES)
This is PHP/Laravel telling you
这是 PHP/Laravel 告诉你的
Hey, I tried to connect to the database with the credentials in my
app/config/database.php
file, but the server told me those credentials were invalid.
嘿,我尝试使用
app/config/database.php
文件中的凭据连接到数据库,但服务器告诉我这些凭据无效。
In other words, the password you configured for "user
" didn't match the actual password, or the "user
" account isn't authorized to access the database service (MySQL?) from the IP address PHP is running.
换句话说,您为“ user
”配置的密码与实际密码不匹配,或者“ user
”帐户未被授权从 PHP 运行的 IP 地址访问数据库服务(MySQL?)。
Use the correct database credentials, and your error will go away. Use the command line mysql
program to test your database credentials.
使用正确的数据库凭据,您的错误就会消失。使用命令行mysql
程序测试您的数据库凭据。
Hopefully that's enough to get you Google-ing for the right thing! :)
希望这足以让您在 Google 上搜索正确的东西!:)