无法读表:ERROR 1018 (HY000): Can't read dir of './jiradb/' (errno: 13)(一)

2014-11-24 17:37:55 · 作者: · 浏览: 0

ERROR 1018 (HY000): Can't read dir of './jiradb/' (errno: 13)



现象:数据库无法正常读表.
[root@jiradb ~]# mysql -ujirakpi -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13366
Server version: 5.5.9-log MySQL Community Server (GPL)


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 |
| bamboo |
| confluence |
| crowd |
| crucible |
| crucibledb |
| jiradb |
| mysql |
| nagiosql |
| performance_schema |
+--------------------+
10 rows in set (0.00 sec)


mysql> use jiradb
Database changed
mysql> show tables;
ERROR 1018 (HY000): Can't read dir of './jiradb/' (errno: 13)
mysql>
mysql> show variables like '%data%';
+----------------------------+----------------------------+
| Variable_name | Value |
+----------------------------+----------------------------+
| character_set_database | utf8 |
| collation_database | utf8_bin |
| datadir | /dataDisk/MysqlData/mysql/ |
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir | |
| innodb_stats_on_metadata | ON |
| max_length_for_sort_data | 1024 |
| myisam_data_pointer_size | 6 |
| skip_show_database | OFF |
| updatable_views_with_limit | YES |
+----------------------------+----------------------------+
10 rows in set (0.00 sec)


mysql>
mysql> use crowd;
Database changed
mysql> show tables;
ERROR 1018 (HY000): Can't read dir of './crowd/' (errno: 13)
mysql>
分析:
人为修改了data目录权限导致:
[root@jiradb mysql]# ls -ld /dataDisk/MysqlData/mysql/jiradb
drwx------ 2 jira mysql 4096 08-28 08:07 /dataDisk/MysqlData/mysql/jiradb
Data目录权限被修改为非mysql账号属主,导致Mysql无权限读取文件,自然获取不到表信息。


解决方案:
修改data目录属主为mysql。
[root@jiradb mysql]# chown -R mysql:mysql /dataDisk/MysqlData/mysql/jiradb
[root@jiradb mysql]#
修改后可正常访问表:
mysql> use jiradb
Database changed
mysql> show tables;
+------------------------------+
| Tables_in_jiradb |
+------------------------------+
| OS_CURRENTSTEP |
| OS_CURRENTSTEP_PREV |
| OS_HISTORYSTEP |
| OS_HISTORYSTEP_PREV |
| OS_WFENTRY |
| SEQUENCE_VALUE_ITEM |
| avatar |
| changegroup |
| changeitem |
| columnlayout |
| columnlayoutitem |
| component |
| configurationcontext |
| customfield |
| customfieldoption |
| customfieldvalue |
| cwd_application |
| cwd_application_address |
| cwd_directory |
| cwd_directory_attribute |
| cwd_directory_operation |
| cwd_group |
| cwd_group_attributes |
| cwd_membership |
| cwd_user |
| cwd_user_0815 |
| cwd_user_0816 |
| cwd_user_attributes |
| external_entities |
| externalgadget |
| favouriteassociations |
| fieldconfigscheme |
| fieldconfigschemeissuetype |
| fieldconfiguration |
| fieldlayout |
| fieldlayoutitem |
| fieldlayoutscheme |
| fieldlayoutschemeassociation |
| fieldlayoutschemeentity |
| fieldscree