Search code examples
mysqlsqlsyntax-errorddl

How to drop a database with "-" on its name in MySQL?


I am trying to drop my databases that are named "login-system" and "test-application" in PHPMyAdmin, but it's giving me an error on the "-" it says "Unexpected token. (near -)".


Solution

  • You can escape object names in MySQL using the backtick character:

    DROP DATABASE `login-system`
    -- Here ------^------------^