Command line wierdness

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Command line wierdness

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Command line wierdness

Post by VladSun »

It seems there is something wrong with the "-" symbol in your database name ... Everything else looks perfect.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Re: Command line wierdness

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Command line wierdness

Post by pickle »

` = backtick

You could also edit the MySQL tables manually.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Re: Command line wierdness

Post 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.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Command line wierdness

Post 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.
Post Reply