ERROR 1018 (HY000): Can’t read dir of ‘./dbname/’ (errno: 13)

When I run the following command at mysql> I get an error which read as follows:

ADVERTISEMENTS

mysql> use dbname;
mysql> show tables;
ERROR 1018 (HY000): Can’t read dir of ‘./dbname/’ (errno: 13)

How do I fix this problem under Debian Linux?

To fix this problem you need to set correct permission on /var/lib/mysql/dbname/ directory. Use the command as follows:
cd /var/lib/mysql/
ls -l
chown mysql:mysql dbname/ -R

Replace dbname with actual database directory name. Now you can connect to your mysql server:
mysql -u user -p dbname -e 'show tables;'

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
10 comments… add one
  • Zoffix Znet Apr 1, 2012 @ 13:13

    Thanks that worked. I was coping the files from an old drive, and even though I used `-p` flag to `cp`, the ownership was weird (wasn’t mysql:mysql)… Not sure what was up with that :)

  • Pavan G Jakati Jul 24, 2012 @ 5:42

    Thank a ton for your valuable effort and heko

  • Mohamed Aug 31, 2012 @ 10:37

    Great, it fixed my problem

  • Mohamed Aug 31, 2012 @ 10:37

    Thanks, you’re helpful

  • kipkajules Oct 30, 2012 @ 18:36

    thanks so much for your entry here! Everywhere else I read suggested this was a number of files open issue, but your answer was correct! I had chown’d it to mysql:root before, but that apparently wasn’t enough.

  • ionut Jun 10, 2013 @ 10:17

    Really thank you for info! It worked very well

  • Robin Jan 24, 2014 @ 10:06

    Sorry to say but it didn’t work for me.
    I am running
    OS : Ubuntu 12.04
    mysql version : 3.4.5
    This problem is on my local system, mysql user name is “root” and password is ” (i.e blank).

    Beers in Advance :)
    Cheers !!

  • Ma Jul 21, 2014 @ 2:32

    Thank you very much. You saved our day.

  • fadlan Feb 9, 2016 @ 14:02

    fix my problem, thanks a lot.. its great

  • Pramod Nov 29, 2017 @ 12:25

    Thanks a lot. Saved my time :)

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.