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


Question

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 :

DATABASES = {
'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

1
37
6/16/2012 7:46:40 PM

Accepted Answer

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/.

70
6/16/2012 7:38:12 PM

For Us OS X Users, this should work:

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

Edit: Depending on how you installed mysql your mileage my vary. I installed using the mysql community server dmg installer on mysql.com

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: /usr/local/mysql/bin/mysql

so my path is /usr/local/mysql/


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon