0

I have two databases in /var/lib/mysql/:

test_@x0m
test_cm

The database test_@x0m has the cyrillic symbol in the name.

In mysql this databases look like:

test_?m
test_cm

I want to remove database with the cyrillic symbol. I use commands:

drop database `test_@x0m`;
drop database `test_?m`;
drop database `test_\?m`;

But get result:

Unknown database

How can i drop database with the cyrillic symbol.

Thank you.

perrfect
  • 15
  • 3
  • Maybe you can use a graphic sql tool for accessing your DBMS like PHPMyAdmin or SQuirrel and then issue your delete command via point and click? – jmizv Aug 10 '20 at 10:36
  • MYsql Workbench has also no problem with your command. – nbk Aug 10 '20 at 10:41

1 Answers1

0

It looks like you need to set the correct encoding when connecting to mysql. First of all check the default encoding variables:

mysql> show variables like '%character%';
+--------------------------+-------------------------------------+
| Variable_name            | Value                               |
+--------------------------+-------------------------------------+
| character_set_client     | latin1                              |
| character_set_connection | latin1                              |
| character_set_database   | latin1                              |
| character_set_filesystem | binary                              |
| character_set_results    | latin1                              |
| character_set_server     | latin1                              |
| character_set_system     | utf8                                |
| character_sets_dir       | /usr/share/percona-server/charsets/ |
+--------------------------+-------------------------------------+

If you see something like that then you need to switch your session settings to UTF8

mysql> SET NAMES utf8;
Query OK, 0 rows affected (0.00 sec)

And now you can delete the database with any utf character by simply entering it into mysql console