13

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;
7ochem
  • 280
  • 1
  • 3
  • 12
hookenz
  • 14,472
  • 23
  • 88
  • 143

1 Answers1

27

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;
John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
Zoredache
  • 130,897
  • 41
  • 276
  • 420