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

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)

Copyright (c) 2000, 2010, 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 |
| 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      |
| fieldscreen                  |
| fieldscreenlayoutitem        |
| fieldscreenscheme            |
| fieldscreenschemeitem        |
| fieldscreentab               |
| fileattachment               |
| filtersubscription           |
| gadgetuserpreference         |
| genericconfiguration         |
| groupbase                    |
| issuelink                    |
| issuelinktype                |
| issuesecurityscheme          |
| issuestatus                  |
| issuetype                    |
| issuetypescreenscheme        |
| issuetypescreenschemeentity  |
| jiraaction                   |
| jiradraftworkflows           |
| jiraeventtype                |
| jiraissue                    |
| jiraperms                    |
| jiraworkflows                |
| label                        |
| listenerconfig               |
| mailserver                   |
| membershipbase               |
| nodeassociation              |
| notification                 |
| notificationinstance         |
| notificationscheme           |
| oauthconsumer                |
| oauthconsumertoken           |
| oauthspconsumer              |
| oauthsptoken                 |
| optionconfiguration          |
| permissionscheme             |
| pluginversion                |
| portalpage                   |
| portletconfiguration         |
| priority                     |
| project                      |
| projectcategory              |
| projectrole                  |
| projectroleactor             |
| projectversion               |
| propertydata                 |
| propertydate                 |
| propertydecimal              |
| propertyentry                |
| propertynumber               |
| propertystring               |
| propertytext                 |
| qrtz_calendars               |
| qrtz_cron_triggers           |
| qrtz_fired_triggers          |
| qrtz_job_details             |
| qrtz_job_listeners           |
| qrtz_simple_triggers         |
| qrtz_trigger_listeners       |
| qrtz_triggers                |
| remembermetoken              |
| resolution                   |
| schemeissuesecurities        |
| schemeissuesecuritylevels    |
| schemepermissions            |
| searchrequest                |
| serviceconfig                |
| sharepermissions             |
| tb_jira_project              |
| trackback_ping               |
| trustedapp                   |
| upgradehistory               |
| upgradeversionhistory        |
| userassociation              |
| userbase                     |
| userhistoryitem              |
| versioncontrol               |
| votehistory                  |
| workflowscheme               |
| workflowschemeentity         |
| worklog                      |
+------------------------------+
121 rows in set (0.01 sec)

mysql>
mysql> use crowd
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_crowd            |
+----------------------------+
| cwd_app_dir_group_mapping  |
| cwd_app_dir_mapping        |
| cwd_app_dir_operation      |
| cwd_application            |
| cwd_application_address    |
| cwd_application_alias      |
| cwd_application_attribute  |
| cwd_directory              |
| cwd_directory_attribute    |
| cwd_directory_operation    |
| cwd_group                  |
| cwd_group_attribute        |
| cwd_membership             |
| cwd_property               |
| cwd_token                  |
| cwd_user                   |
| cwd_user_attribute         |
| cwd_user_credential_record |
| hibernate_unique_key       |
+----------------------------+
19 rows in set (0.22 sec)

mysql> update set host = "%" where user = "root";Ctrl-C -- exit!
Aborted
[root@jiradb ~]#

你可能感兴趣的:(Mysql)