spatie / laravel-backup

A package to backup your Laravel app

Home Page:https://spatie.be/docs/laravel-backup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mysqldump: Got error: 2002: "Can't connect to MySQL server on '127.0.0.1' (60)" when trying to connect

kidereo opened this issue · comments

I have installed the latest laravel-backup package on PHP8.2 and Laravel 9.54 and get the above message on every attempt to make a backup.

Running config('database.connections.mysql') returns
[ "driver" => "mysql", "url" => null, "host" => "127.0.0.1", "port" => "3306", "database" => "test_database", "username" => "root", "password" => "", "unix_socket" => "", "charset" => "utf8mb4", "collation" => "utf8mb4_unicode_ci", "prefix" => "", "prefix_indexes" => true, "strict" => true, ]

The connection is there because the Laravel app itself works and accesses the database just fine. I can also connect to the database through Sequel Ace.

All suggestions would be greatly appreciated. Many thanks for the package!

Solved! Just in case anybody else has this problem the solution is simple. By default, Laravel specifies DB_HOST=127.0.0.1 in the .env. Simply change to DB_HOST=localhost for everything to work as intended.