有一天MYSQL发现,有这样的数据库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| #mysql50#.ssh |
| mysql |
| performance_schema |
+--------------------+
或者drop database \#mysql50\#.ssh'又或者drop database \\#mysql50\\#\\.ssh
mysql> drop database #mysql50#.ssh;
ERROR : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> drop database "#mysql50#.ssh";
ERROR : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"#mysql50#.ssh"' at line 1
都报错,后来发现,mysql用户的$HOME目录下有目录.ssh导致的问题。
su - mysql
pwd
ll .ssh
$rm -rf .ssh后,问题解决
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| #mysql50#.ssh |
| mysql |
| performance_schema |
+--------------------+
以为是哪位大神失误创建的
或者drop database \#mysql50\#.ssh'又或者drop database \\#mysql50\\#\\.ssh
mysql> drop database #mysql50#.ssh;
ERROR : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> drop database "#mysql50#.ssh";
ERROR : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"#mysql50#.ssh"' at line 1
都报错,后来发现,mysql用户的$HOME目录下有目录.ssh导致的问题。
su - mysql
pwd
ll .ssh
$rm -rf .ssh后,问题解决
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
本文介绍了一种因特殊字符导致无法删除MySQL数据库的问题及解决方案。通过排查发现,mysql用户的家目录存在.ssh文件夹,这与待删除的数据库名称冲突,导致删除失败。最终通过删除家目录下的.ssh文件夹解决了问题。
2万+

被折叠的 条评论
为什么被折叠?



