一、问题描述


在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> 

 

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:22 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐