0

I would like to run a mysql command using a Powershell but getting an syntax error because of the accent mark (`).

mysql -u root -p -e "GRANT ALL PRIVILEGES ON `testuser\_%` . * TO 'testuser'@'localhost';"

mysql : ERROR at line 1: Unknown command '\_'. At line:1 char:1 + mysql -u root -e "GRANT ALL PRIVILEGES ON `testuser\_%`.* TO ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (ERROR at line 1: Unknown command '\_'.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError

Looks like a Powershell confuses this part `testuser\_%` or \_% Any suggestions?

Let MySQL users create databases, but allow access to only their own databases

1 Answer 1

0

Yes, because the backtick

`

is the literal escape character in PowerShell.

You can get around this by using single quotes to define your string

'

How about doing this?

$query = 'GRANT ALL PRIVILEGES ON `testuser\_%` .  * TO testuser@localhost'
mysql -uroot -p -e "$query"
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.