繁体   English   中英

SQLSTATE[HY000] [2002] 连接被拒绝 LARAVAL

[英]SQLSTATE[HY000] [2002] Connection refused LARAVEL

我正在尝试在我刚刚创建的新数据库上运行php artisan migrate 我在连接到 mariadb 时遇到了很多麻烦,但我设法解决了它。 现在,每当我尝试连接它时,出于某种原因,我无法输入密码或几乎任何密码,但我仍然可以连接到它。 我不知道这是否正常。 无论如何,我将 Laravel 项目中的.env文件修改为

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=liberty_comerce
DB_USERNAME=root
DB_PASSWORD=

但我收到错误SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = liberty_comerce and table_name = migrations and table_type = 'BASE TABLE') 如果我将DB_HOST=127.0.0.1更改为DB_HOST=localhost我得到错误SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = liberty_comerce and table_name = migrations and table_type = 'BASE TABLE')

我试过跑步

php artisan config:clear
php artisan config:cache
php artisan cache:clear

每次我改变任何东西。 我一直在网上寻找答案,但似乎没有任何效果。

.env DB_PORT 与您的本地数据库端口不匹配时,连接被拒绝。 所以首先检查端口,然后清除缓存命令:

php artisan config:clear
php artisan config:cache
php artisan cache:clear

然后做php artisan migrate

我有同样的问题还没有得到解决方案,我尝试了一些事情,比如将 127.0.0.1 更改为本地主机,以及php artisan config:clear php artisan config:cache php artisan cache:clear

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM