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

when i try to view the databases in mysql i get this error:

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

And that stops my app from displaying…

My django debugger says:

(2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/my_database' (13)")

Here is my settings file :

'default': {
    'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': 'my_database',                      # Or path to database file if using sqlite3.
    'USER': 'root',                      # Not used with sqlite3.
    'PASSWORD': '****',                  # Not used with sqlite3.
    'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
    'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.

What can cause the problem?

Thanks in advance


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You need to set ownership and permissions for directory:

chown -R mysql:mysql /var/lib/mysql/ #your mysql user may have different name
chmod -R 755 /var/lib/mysql/

Note: -R makes commands recursive – you may omit it, if there is no subdirs in /var/lib/mysql/.

Method 2

This should work for Mac users:

sudo chown -R mysql:mysql /usr/local/mysql/
sudo chmod -R 755 /usr/local/mysql/

If this doesn’t work, try running which mysql to see where your mysql installation is located, and then replace /usr/local/mysql/ in the command above with whatever is before the ‘bin’ directory.

For example, on my system which mysql produces the following output:


so my path is /usr/local/mysql/

Method 3

On CentOS/RedHat, you should do the same thing on a different path:

chown -R mysql:mysql /data/mysql/
chmod -R 755 /data/mysql/

Method 4

chown -R mysql:mysql /var/lib/mysql/

chmod -R 755 /var/lib/mysql/

I can confirm that these two chmod statements worked for me (Webmin didn’t see the databases nor did show tables) but I’m not sure why I had to do this after setting up perhaps two dozen servers (Centos) with MySQL in that past few years.

Method 5

osx high sierra use the following command solves the issue:

chown -R mysql:mysql /usr/local/mysql

Method 6

if you installed mariadb using homebrew you can run the following the command for OS X

sudo chown -R mysql:mysql /var/lib/var/mysql/
sudo chmod -R 777 /usr/local/var/mysql/

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x