简体   繁体   中英

Laravel and Mysql 'has gone away'

I'm trying to set up a new project on MacOS (and it is a first time for me). After a while I managed to have a MySQL instance that seemed correct (as I could connect both from a client and the command line).

However, if I try to run anything from my Laravel project, I get the 'MySQL server has gone away' exception. This started when I tried to run the (very small) migrations from my project, but is not related to the size of them. I dug deeper, and tried to use Tinker and a basic

DB::connection()->getPdo();
command. This works fine on my Windows environment, as well as Linux. Not on Mac OS. I even tried connecting with a wrong password, and I got the same exception (as opposed as the 'Wrong Password' expected exception).

So there is definitely something fishy going on in my configuration, however I'm not sure how to investigate further. Any help would be appreciated. Thanks!

Edit: .env

APP_NAME=app
APP_ENV=local
APP_KEY=base64:0aifOBV0BKky/eo9MVxdtY4SUJPsGMS3qkWhlo3r7gI=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=app
DB_USERNAME=root
DB_PASSWORD=
DB_ENGINE=InnoDB

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

尝试在mysql配置中增加max_allowed_packet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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