I am running into this error. I am able to connect to the database with the correct credentials and I can run mysqldump from the terminal with the same credentials. I have tried setting the binary path with no luck. I have tripled checked that I am using the correct credentials. I have tried changing the host from '127.0.0.1' to localhost. I have this package on other laravel sites on the same server with no issue. I am almost ready to give up. Any help would be appreciated. Thank you.
Exception message: The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 2003: Can't connect to MySQL server on '127.0.0.1' (111) when trying to connect
Have you tried running php artisan config:clear?
If I change the host from 127.0.0.1 to localhost in my .env file I now get this error:
Exception message: The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
This probably has nothing to do with the package, but with permissions on your machine.
Hmm permissions look fine. I am able to use a cron job to run the artisan backup:run command so I will just use that instead of the scheduler.
Thanks for the help
@derekbliss Were you able to solve this?
@derekbliss Were you able to solve this?
Not exactly. I did not get the scheduler to work but for whatever reason I am able to run the backup command with a cron job which does the same thing.
php artisan backup:run
Thanks @derekbliss!
Seems related to the issue mentioned here. It seems calling commands over http invokes additional security measures.
I'm not sure how to negate these measures. Let me know if you find a solution to this 馃槃
@derekbliss @sandervanhooft was this ever resolved? It seems like I'm running into the same issue with the Spatie Nova Backup Tool that uses this Backup Tool.
backup:run from the command line works perfectly fine, however when I click the 'Create Backup' button in Nova (calling the command over http?) I get the same error: The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 2003: Can't connect to MySQL server on '127.0.0.1' (61) when trying to connect
Note that I use localhost in my .env file for DB_HOST, as 127.0.0.1 gives the same error when invoking backup:run from the command line. More details in this issue.
@joostvanhoof I haven't found a solution for this.
Perhaps related: https://stackoverflow.com/questions/5426856/cant-get-mysqldump-to-connect-to-local-mysql-instance-error-2003-10061
Thanks. In the end, things magically started working and I don't know why... This is all slightly hocus pocus to me, but here below my full config, hope this helps others!
Setup
Using MAMP Pro and PHP 7.2.9
In .env:
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
DB_HOST=localhost (127.0.0.1 definitely doesn't work)
Edited my .bash_profile and added:
export PATH="$PATH:/Applications/MAMP/Library/bin"
In terminal executed the following commands (as per this SO post):
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
sudo ln -s /Applications/MAMP/Library/bin/mysqlcheck /usr/local/bin/mysqlcheck
sudo ln -s /Applications/MAMP/Library/bin/mysqldump /usr/local/bin/mysqldump
Queue worker
And if I'm correct you need to make sure that a queue worker is started using php artisan queue:work.
Nice, thanks for sharing! 馃槃 I also read somewhere that updating mysqldump fixed it.
If it can be useful to someone, I got a similar error on a Bitnami LAMP installation on AWS:
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
solved adding to database.php in the connection/mysql section :
'dump' => [
'dump_binary_path' => '/opt/bitnami/mysql/bin',
'add_extra_option' => '--socket=/opt/bitnami/mysql/tmp/mysql.sock', ]
Adding the 'dump_binary_path' => '/usr/bin/' within a "dump" array within config/database.php (see https://spatie.be/docs/laravel-backup/v6/installation-and-setup#dumping-the-database) did not work for me.
I still get:
The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Couldn't execute 'SELECT COLUMN_NAME...
This worked for me though:
sudo vim /etc/mysql/my.cnf
Then edit as mentioned in https://stackoverflow.com/a/52423596/470749, and then restart your MySQL.
Most helpful comment
If it can be useful to someone, I got a similar error on a Bitnami LAMP installation on AWS:
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connectsolved adding to database.php in the connection/mysql section :