Laravel 6.4.1 SQLSTATE[HY000] [2002] Connection refused(Laravel 6.4.1 SQLSTATE[HY000] [2002] 连接被拒绝)
问题描述
我是 Laravel 开发的新手.我已在我的 Mac Mojave 10.14.6 上将 Xampp 更新到 7.3.11.在 Laravel 项目中,当我点击 php artisan migrate 命令时出现以下错误.
I am new in Laravel development. I have updated Xampp to 7.3.11 on my Mac Mojave 10.14.6. In Laravel project when I hit php artisan migrate command I got following error.
SQLSTATE[HY000] [2002] 连接被拒绝(SQL: select * frominformation_schema.tables 其中 table_schema = laravel 和 table_name= 迁移和 table_type = 'BASE TABLE')
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
当我启动 Xampp 服务时,我的管理面板运行在 http://127.0.0.1:8080/phpmyadmin一个>.我在 Laravel 的工作项目也没有连接数据库,说连接被拒绝.我尝试更改 .env 文件中的 DB_Port 和 DB_Host .我尝试清除缓存.
When I start Xampp service, my admin panel run on http://127.0.0.1:8080/phpmyadmin.
My working project in Laravel is also not connecting with database saying connection refused.
I tried by changing DB_Port and DB_Host in .env file.
I tried by clearing cache.
任何帮助将不胜感激.
我的 .env 文件
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
推荐答案
打开 localhost/phpmyadmin 并找到一个名为 User accounts 的选项卡.
Open localhost/phpmyadmin and find a tab called User accounts.
找到 root 用户并在你的 .env 中设置它的密码,如果它也不要忘记创建名为 laravel 的数据库不存在
Find the root user and set its password in your .env and also don't forget to create the database named laravel if it doesn't exist
然后你可以清除配置缓存
Then you can clear config cache
php artisan config:clear
然后迁移
php artisan migrate
这篇关于Laravel 6.4.1 SQLSTATE[HY000] [2002] 连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel 6.4.1 SQLSTATE[HY000] [2002] 连接被拒绝
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
