2

I've got a bash script that runs a series of sql statements:

#!/bin/bash

mysql -u root -p << QUERY_INPUT

CREATE DATABASE dba_first;
CREATE DATABASE dba_second;
CREATE DATABASE dba_third;

GRANT ALL PRIVILEGES ON `dba%`.* TO `dbuser`@`localhost`;

QUERY_INPUT

When I run the script, I get: ./quick.sh: line 20: dba%: command not found

Any suggestions please?

2
  • 1
    What is on line 20? Commented May 31, 2016 at 14:34
  • It was the `dba%` backticks not being escaped properly. Commented Jun 1, 2016 at 5:48

1 Answer 1

2

Answered by a nice person on IRC; have to escape the `

GRANT ALL PRIVILEGES ON \`dba%\`.* TO \`dbuser\`@\`localhost\`;
Sign up to request clarification or add additional context in comments.

Comments

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.