tags:

views:

16

answers:

2

Is there a way to escape a hyphen with the mysql commandline tool?

I basically need to do this:

$ mysql -hlocalhost -uuser -puser information_schema -e "CREATE DATABASE foo-bar"

Using mysqladmin is not an option due to the framework I'm within.

+1  A: 

"CREATE DATABASE \`foo-bar\`"

tandu
+1  A: 

Hi!

Using backticks and using this way of piping the statement to mysql works:

echo 'create database `foo-bar2`' | mysql -uuser -ppassword

// John

John P
You don't need to hijack my answer :)
tandu