1

This is part of a Bash script, and the inside looks like this:

createdbcmd="docker exec $1 mysql -v -uroot -e \"GRANT ALL PRIVILEGES ON $dbname.* TO $2@$4 IDENTIFIED BY '$3'\"" 
echo $createdbcmd
$createdbcmd

the echo looks like this:

docker exec mysql_test_no mysql -v -uroot -e "GRANT ALL PRIVILEGES ON wordpress.* TO [email protected] IDENTIFIED BY 'changeme'" 

Running this exact command works just fine. via the bash-script it acts as if i'm just running 'mysql' and i get the default help information with no error.

1 Answer 1

2

Try this way:

createdbcmd="docker exec $1 mysql -v -uroot -e \"GRANT ALL PRIVILEGES ON $dbname.* TO $2@$4 IDENTIFIED BY '$3'\"" 
echo $createdbcmd
eval $createdbcmd

Without the eval, the quoted expression is not interpreted correctly.

Sign up to request clarification or add additional context in comments.

1 Comment

@user3009620 Then please mark it as accepted! (See that pipe/check shaped icon below the voting arrows next to my post, on the left.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.