Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Unfortunately, I have a database name with a dash in it. How do I grant access to that database as mysql reports a syntax error.

e.g.

grant select,insert,update,delete on astpp.* to 'portal'@'localhost' identified by 'Ab7g12Xh35' with grant option;

works, but

grant select,insert,update,delete on astpp-eth01.* to 'portal'@'localhost' identified by 'Ab7g12Xh35' with grant option;

Does not.

Neither does: grant select,insert,update,delete on 'astpp-eth01'.* to 'portal'@'localhost' identified by 'Ab7g12Xh35' with grant option;

share|improve this question
up vote 12 down vote accepted

On mysql you escape database column names with the backtick character unless you have ANSI_QUOTES enabled. See http://dev.mysql.com/doc/refman/5.0/en/identifiers.html.

Try using a command like this.

grant select,insert,update,delete on `astpp-eth01`.* to 'portal'@'localhost' identified by 'Ab7g12Xh35' with grant option;
share|improve this answer
    
Brilliant! that worked a treat. Thanks man! – Matt May 7 '10 at 1:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.