Skip to content

Misuse of shell builtins. #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yadounis opened this issue Mar 16, 2016 · 27 comments
Closed

Misuse of shell builtins. #92

yadounis opened this issue Mar 16, 2016 · 27 comments

Comments

@yadounis
Copy link

Hi,
I got this problem when running backup:run

Starting backup... Dumping database prostats_db... Backup failed because The dump process failed with exitcode 2 : Misuse of shell builtins. Backup completed!

I'm running on L5.2, PHP5.6 and Debian 8

@freekmurze
Copy link
Member

Could you try running a shell command via php?

@yadounis
Copy link
Author

Yes i can

@freekmurze
Copy link
Member

Could you try calling mysqldump specifically through php?

@yadounis
Copy link
Author

Yes i can do that too, through system()

@freekmurze
Copy link
Member

Could you try running a command using symfony/process

http://symfony.com/doc/current/components/process.html

@heikoeln
Copy link

I have the same problem with two environments:
codeanywhere dev-box: Ubuntu 14.04 with PHP 5.5.9 - Laravel 5.2
digitalocean droplet: Ubuntu 14.04 with PHP 5.5.9 - Laravel 5.2

php artisan backup:run --only-files works! I guess it uses symfony/process too.

I think it's a problem with mysqlbackup.

mysqldump -umyusr -pmypwd --database dbname works.

php -r "system('mysqldump -umyusr -pmypwd dbname');" works too.

But php artisan backup:run --only-db fails.

@freekmurze
Copy link
Member

--only-files doesn't use symfony process. Could you try if dumping the db using spatie/db-dumper works? (That package is used under the hood of laravel-backup)

@heikoeln
Copy link

Another two tests:

File backuptest.php:
<?php
include 'vendor/autoload.php';
Spatie\DbDumper\Databases\MySql::create()
->setDbName('dbname')
->setUserName('myusr')
->setPassword('mypwd')
->dumpToFile('test.sql');

php backuptest.php Works fine! (spatie/db-dumper version 1.2.2)
)

File symfonytest.php:
<?php
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
$process = new Process('mysqldump -umyusr -pmypwd dbname');
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();

php symfonytest.php Was successful too. (symfony/process version 3.0.3)

@freekmurze
Copy link
Member

Thank you for running these tests. I'm a bit stumped because under the hood laravel-backup does what you've done in your tests.

Are you running your tests and laravel-backup on the command line?

@heikoeln
Copy link

Yes, i used the same shell for this three commands:

me@server:/path/to/approot$ php artisan backup:run
me@server:/path/to/approot$ php backuptest.php
me@server:/path/to/approot$ php symfonytest.php

@sebastiandedeyne
Copy link
Member

Wild guess—

Could you edit lines 173-178 in vendor/spatie/db-dumper/src/Databases/MySql.php:

$command = [
    "{$this->dumpBinaryPath}mysqldump",
    "-h {$this->host}",
    "--defaults-extra-file={$temporaryCredentialsFile}",
    '--skip-comments',
    $this->useExtendedInserts ? '--extended-insert' : '--skip-extended-insert',
];

(added that -h flag)

@heikoeln
Copy link

The -h flag was not the problem... PEBCAK!
I configured usr/bin/mysqldump for dump_command_path in config/database.php.

I'm very sorry for the inconvenience... -.-

@yadounis Perhaps you did the same.

@freekmurze
Copy link
Member

I'll update our documentation to make it more clear that it should only be the path to the binary that should be filled in.

@yadounis
Copy link
Author

@heikoeln can you please give me more details on how you solved this issue ? Your answer is not clear for me. Thanks.

@heikoeln
Copy link

@yadounis
I configured 'dump_command_path' => '/usr/bin/mysqldump', in config/database.php.

But this is right (path only):
'mysql' => [
'driver' => 'mysql',
'dump_command_path' => '/usr/bin',
[...]
],

@yadounis
Copy link
Author

Both are not working for me, still have the same issue !

capture d ecran 2016-03-23 a 09 29 49

capture d ecran 2016-03-23 a 09 31 11

@heikoeln
Copy link

@yadounis
Your config is still wrong.
Change it to 'dump_command_path' => '/usr/bin',
(without mysqldump)

@yadounis
Copy link
Author

I tested both configs :
'dump_command_path' => '/usr/bin'
and
'dump_command_path' => '/usr/bin/mysqldump'

and both are resulting with the same error

@heikoeln
Copy link

Ah ok. I understand. Path only is the only way that shoud work.
Are you sure that the conifgured mysql user has the minimum grants for mysqldump? Esp. LOCK TABLES is needed.

@yadounis
Copy link
Author

Yes, it was a privilages issue, its worked when i used the mysql root.

thanks 👍

@todayqq
Copy link

todayqq commented Jun 20, 2017

和环境是有关系的,如果laravel是在Homestead环境下,必须要进入虚拟机里面执行

vagrant ssh
cd /path
php artisan backup:run

@shahmir811
Copy link

I am facing the same issue in Laravel 5.7, php 7.1.
Will someone kindly update ?

@alexinside
Copy link

What privileges it needs?

@shahmir811
Copy link

Got a solution.
Place your laravel application inside xamp(htdocs) or wamp

stop php artisan serve

then enter following in your browser

localhost/My_APP_NAME/public

@willbrowningme
Copy link

Was having this same issue on a production server.

The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 1045: "Access denied for user 'user'@'localhost' (using password: YES)" when trying to connect

I eventually solved it by updating the database user's password and removing special characters such as #.

@neilodiaz
Copy link

neilodiaz commented Mar 26, 2019

After digging on the spatie/db-dumper library, it seems that the --defaults-extra-file on here doesn't work for me. Always returning this error:

Backup failed because The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES)...

I tried changing it to --defaults-file and now its working fine. Not sure what happened behind-the-scene. Can someone enlighten me?

My Setup:

"laravel/framework": "5.1.*",
"spatie/laravel-backup": "^3.0.0",

PS: This is an old project and haven't upgraded the Laravel version since.
Edit: Related issue

@valiantboymaksud
Copy link

add if you xampp: /Applications/Xampp/bin
if you using Mamp: /Applications/Mamp/Library/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants