Page 1 of 1

Command line wierdness

Posted: Mon Jan 14, 2008 4:02 pm
by MrPotatoes
i'm on the command line and i'm trying to grant privileges to a user. normally i can do this with no issues but this is a different case that i was not aware of

i have a database with this format: databasename-suffix.

the dash it throwing it off. here are the queries that i run and the errors i get:

Code: Select all

GRANT select
ON database-name
TO me;
 
[[b]error[/b]]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-dev
TO me' at line 2
 
or this one:

Code: Select all

GRANT select
ON 'database-name'
TO me;
 
[[b]error[/b]]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''database-name' TO me' at line 2
 
one last one

Code: Select all

GRANT select
ON database-name.*
TO me;
 
[[b]error[/b]]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-dev.*
TO me' at line 2
 
i can't figure out a way around this. can i receive some help on this? thank you

Re: Command line wierdness

Posted: Mon Jan 14, 2008 4:20 pm
by VladSun
It seems there is something wrong with the "-" symbol in your database name ... Everything else looks perfect.

Re: Command line wierdness

Posted: Mon Jan 14, 2008 4:29 pm
by MrPotatoes
i figured it out. the problem is that MySQL allows me to use single quotes and the ` character. i have no idea what that one is called

anyways, this is what i did and it worked:

Code: Select all

GRANT SELECT, INSERT, DELETE, UPDATE
ON `databasename-suffix`.*
TO me;
that's what you wanna do and that's how it's done folks

*bows*

lol.

Re: Command line wierdness

Posted: Mon Jan 14, 2008 5:22 pm
by pickle
` = backtick

You could also edit the MySQL tables manually.

Re: Command line wierdness

Posted: Mon Jan 14, 2008 5:27 pm
by MrPotatoes
that's right. backtick. i just couldn't remember it for the life of me lol. i used them when i wrote macros sometimes.

i would change the table manually but it's just not the best option. i have access to the dev but i may not have access to stage and production. so to know it by the command line is best. i can give the command to the systems people when the time is needed.

Re: Command line wierdness

Posted: Fri Jan 18, 2008 2:38 pm
by Mordred
For 'quoting' stuff in MySQL we use:
` (backtick) for identifiers - databases, columns, etc.
' (quote) for values

I think the SQL standard also requires double quotes, but it's good to pick one and use it consistently. I use single quotes, because I put my SQL statements in double quotes.