我试图从information_schema中选择数据,但是我得到了以下错误。我怎么才能解决这个问题?
mysql> SELECT * FROM information_schema.tables ;
ERROR 1018 (HY000): Can't read dir of '.' (errno: 13)发布于 2011-11-18 13:50:52
我发现这个错误特别令人不安,因为MySQL引入了INFORMATION_SCHEMA并引入了MySQL 5.0。@gbn的答复显示了这个bug
MySQL对数据库的定义只是datadir下的一个子文件夹。
现在,我发现这个错误特别令人不安: INFORMATION_SCHEMA数据库不应该是datadir下的已显示文件夹。
例如
转到操作系统并运行以下命令:
cd /var/lib/mysql
ls -l您将看到几个文件夹:
在mysql中,当您执行SHOW DATABASES;时,不应该看到.和..。源代码会确保这一点。现在,INFORMATION_SCHEMA在哪里?你猜怎么着?INFORMATION_SCHEMA中的所有表都是临时表,并使用内存存储引擎。还请注意,您没有看到一个名为INFORMATION_SCHEMA的文件夹。现在,查看INFORMATON_SCHEMA.TABLES的定义:
mysql> use information_schema
Database changed
mysql> show create table tables\G
*************************** 1. row ***************************
Table: TABLES
Create Table: CREATE TEMPORARY TABLE `TABLES` (
`TABLE_CATALOG` varchar(512) NOT NULL DEFAULT '',
`TABLE_SCHEMA` varchar(64) NOT NULL DEFAULT '',
`TABLE_NAME` varchar(64) NOT NULL DEFAULT '',
`TABLE_TYPE` varchar(64) NOT NULL DEFAULT '',
`ENGINE` varchar(64) DEFAULT NULL,
`VERSION` bigint(21) unsigned DEFAULT NULL,
`ROW_FORMAT` varchar(10) DEFAULT NULL,
`TABLE_ROWS` bigint(21) unsigned DEFAULT NULL,
`AVG_ROW_LENGTH` bigint(21) unsigned DEFAULT NULL,
`DATA_LENGTH` bigint(21) unsigned DEFAULT NULL,
`MAX_DATA_LENGTH` bigint(21) unsigned DEFAULT NULL,
`INDEX_LENGTH` bigint(21) unsigned DEFAULT NULL,
`DATA_FREE` bigint(21) unsigned DEFAULT NULL,
`AUTO_INCREMENT` bigint(21) unsigned DEFAULT NULL,
`CREATE_TIME` datetime DEFAULT NULL,
`UPDATE_TIME` datetime DEFAULT NULL,
`CHECK_TIME` datetime DEFAULT NULL,
`TABLE_COLLATION` varchar(32) DEFAULT NULL,
`CHECKSUM` bigint(21) unsigned DEFAULT NULL,
`CREATE_OPTIONS` varchar(255) DEFAULT NULL,
`TABLE_COMMENT` varchar(2048) NOT NULL DEFAULT ''
) ENGINE=MEMORY DEFAULT CHARSET=utf8
1 row in set (0.05 sec)我把这个错误完全归咎于源代码,因为mysql绕过了.和..作为不被视为数据库的特例文件夹,INFORMATION_SCHEMA也被认为是S特例文件夹,也是一个在datadir下没有显示文件的特例文件夹。
我强烈建议只将MySQL升级到最新版本,因为正如@gbn所发现的,有一个bug报告,但它被标记为已关闭。这只会发生
@gbn从我那里得到一个+1,因为我找到了bug报告,这有助于我更深入地研究
发布于 2011-11-18 08:32:22
权限错误,(报告为(旧的) MySQL错误
检查MySQL安装文档中的权限位
发布于 2012-09-24 05:59:50
在MySQL版本5.5中,NFORMATION_SCHEMA目录/文件夹存在;我假设它会在其他版本上存在。它不受my.ini或my.cnf设置为datadir=whatever的控制;它似乎是在MySQL的安装路径中预先定义的,并且在MySQL第一次启动时被读取。
没有用于放置此架构的位置的my.ini或my.cnf设置。这似乎既适用于Unix/Linux版本的MySQL 5.5,也可能追溯到该模式首次引入时。在Windows和Unix框中,我从4.1到5.5,所以我不知道两者之间的版本。
我忘记提到我的示例中的文件夹不是模式的名称,而是另一个名为MySQL的文件夹,其中有一个名为information_schema.mbp的目录/XML文件,其中包含以下数据,正如您在MySQL管理客户机中可能看到的那样。我想这就是它在启动时加载到内存中的副本。我看到我的版本似乎比你的长,我的也有一个用户配置部分。
如果您没有在我的系统上使用常规的datadir或sqldump备份这一点,您将失去用户配置设置和权限。还有其他类似的文件包含表的实际数据。我猜.mbp扩展是用来表示内存引擎备份或复制的。我知道它必须存放在某个地方,而且必须有一种方法来访问它。
升级到5.5时,我确实导入了我的旧用户配置和权限。他们是由服务器发送到这个数据库的。然而,它并没有像过去那样被拯救。因此,如果和当您使用我的版本,您将需要备份这个文件,否则您将失去您的所有用户和权限。我想这就是我这个内置数据库的目的。
<?xml version="1.0"?>
<backup_profile>
<profile_name>information_schema</profile_name>
<last_used></last_used>
<options>288</options>
<backup_type>0</backup_type>
<tables>
<table>
<name>CHARACTER_SETS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>COLLATIONS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>COLLATION_CHARACTER_SET_APPLICABILITY</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>COLUMNS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>COLUMN_PRIVILEGES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>ENGINES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>EVENTS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>FILES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>GLOBAL_STATUS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>GLOBAL_VARIABLES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>KEY_COLUMN_USAGE</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>PARAMETERS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>PARTITIONS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>PLUGINS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>PROCESSLIST</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>PROFILING</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>REFERENTIAL_CONSTRAINTS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>ROUTINES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>SCHEMATA</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>SCHEMA_PRIVILEGES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>SESSION_STATUS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>SESSION_VARIABLES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>STATISTICS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>TABLES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>TABLESPACES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>TABLE_CONSTRAINTS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>TABLE_PRIVILEGES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>TRIGGERS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>USER_PRIVILEGES</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>VIEWS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_CMP_RESET</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_TRX</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_CMPMEM_RESET</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_LOCK_WAITS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_CMPMEM</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_CMP</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
<table>
<name>INNODB_LOCKS</name>
<schema>information_schema</schema>
<catalog>def</catalog>
</table>
</tables>
</backup_profile>抱歉,这太大了!我想让你看看它是什么样子,怎么用名字找到它。嗯,我还没有试过它,但是我想知道您是否在它当前的位置创建了另一个数据文件,如果它在启动时加载,是否会创建相同的文件扩展名呢?也就是说,如果您真的想以这种方式创建数据库的话。
https://dba.stackexchange.com/questions/8087
复制相似问题