工匠-SQLSTATE [HY000] [2003]无法连接到"127.0.0.1"上的MySQL服务器 [英] artisan - SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1'
本文介绍了工匠-SQLSTATE [HY000] [2003]无法连接到"127.0.0.1"上的MySQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行了命令:"php artisan migration",并显示了以下错误消息:
I ran the command: "php artisan migrate" and got the error message displayed below:
[PDOException]
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)
有什么问题,我该如何解决?
What's the problem and how do I fix it?
推荐答案
可能存在以下可能性-
- 您没有在应用程序根目录下的.env文件中为mysql访问设置正确的凭据.
解决方案-在首选编辑器中打开.env文件,并检查所有mysql访问凭据是否正确.
Solution - Open .env file in your preferred editor and check if all the mysql access credentials are correct.
类似-
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=[your db name here]
DB_USERNAME=[db user here]
DB_PASSWORD=[password]
- 用户凭据无权访问您在.env文件中提到的mysql或数据库
- mysql未运行-根据您的操作系统(windows,ubuntu ..)检查mysql是否正在运行
解决方案-使用任何mysql界面(phpmyadmin,workbench..etc)检查您在.env文件中提到的用户是否具有足够的连接权限.
Solution - use any mysql interface (phpmyadmin, workbench..etc) to check if the user that you mentioned in .env file have enough access to connect.
这篇关于工匠-SQLSTATE [HY000] [2003]无法连接到"127.0.0.1"上的MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文