mysql-删除数据库时报错ERROR 1008 (HY000): Can‘t drop database ‘studyfunction‘; database doesn‘t exist

一、问题描述


在linux系统的mysql中,当我删除已经存在的数据库studyfunction时,报错studyfunction这个数据库不存在,可是我 show databases;发现这个数据库明明存在。网上查找了各种原因没有找到解决的办法,于是我分析了一下产生这个问题的原因:我之前修改了mysql区分大小写,才出现的的这个问题,所以我猜测,当我设置了不区分大小写,大写的studyfunction这个数据库底层逻辑被修改了,所以找不到它

解决办法:

        先exit退出mysql,然后打开etc/my.cnf文件,注释掉lower_case_table_names=1这一行,

       1、打开文件: vi /etc/my.cnf
  2、在[mysqld]下的 lower_case_table_names=1这一行前面加 #
  3、重新启动数据库 :service mysqld restart

       4、重启成功后,show databases;显示所有数据库,然后drop掉你不需要的数据库,在重复上面123过程,将2中lower_case_table_names=1前面的#号删掉,设置mysql操作不区分大小写。

下面附上操作的完整代码仅供参考:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| STUDYFUNCTION      |
| db_study_function  |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> drop database STUDYFUNCTION;
ERROR 1008 (HY000): Can't drop database 'studyfunction'; database doesn't exist
mysql> exit
Bye
[root@localhost ~]# vi /etc/my.cnf
[root@localhost ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| STUDYFUNCTION      |
| db_study_function  |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> drop database STUDYFUNCTION;
Query OK, 0 rows affected (0.04 sec)

mysql> 

 

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值