python - mysql错误: ERROR 1018 (HY000): Can't read dir of '.' (errno: 13)

标签 python mysql database django permissions

当我尝试在 mysql 中查看数据库时,出现此错误:

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

这会阻止我的应用显示...

我的 django 调试器说:

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

这是我的设置文件:

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.

什么可能导致问题?

提前致谢

最佳答案

您需要为目录设置所有权和权限:

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

注意:-R 使命令递归 - 如果 /var/lib/mysql/ 中没有子目录,您可以省略它。

关于python - mysql错误: ERROR 1018 (HY000): Can't read dir of '.' (errno: 13),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11066411/

相关文章:

python - 如何使用shutil.make_archive创建zip64存档

python - 哪些Web服务器与gevent兼容,两者之间有何关系?

php - 从一个表中获取多行并存储到php Mysql中的另一个表

sql-server - 当我有 "IsDeleted"列类型的日期时间列时,是否需要 bool 列?

mysql - 使用 sql 将大型 csv 文件导入 phpmyadmin 时出现问题

mysql - 想要找到旧数据库

python - 从我的本地开发机器正确指定 git pull 的路径

python - 将列表写入文件以供日后重用

mysql - 全世界街道的数据库?

mysql - CodeIgniter数据库错误覆盖