mysqldatabasemariadbrootvesta

Why i cannot remove database?


MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| admin_default      |
| information_schema |
| mysql              |
| openvpn-admin      |
| performance_schema |
| roundcube          |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [(none)]> drop database 'openvpn-admin';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''openvpn-admin'' at line 1
MariaDB [(none)]> drop database openvpn-admin;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-admin' at line 1
MariaDB [(none)]>

I'm triggered. mariadb + vestacp i cannot delete database WHY? what's goin on???


Solution

  • It's down to your use of "-" in the schema name.

    You quote identifiers with backticks ` or double quotes " (if you have ANSI_QUOTES sql_mode enabled) so it will work with

    drop database `openvpn-admin`;