简体   繁体   English

mysql 错误:错误 1018 (HY000):无法读取 '.' 的目录 (错误号:13)

[英]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:当我尝试在 mysql 中查看数据库时出现此错误:

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

And that stops my app from displaying...这会阻止我的应用程序显示...

My django debugger says:我的 Django 调试器说:

(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提前致谢

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/ .注意: -R使命令递归 - 如果/var/lib/mysql/中没有子目录,您可以省略它。

This should work for Mac users:这应该适用于 Mac 用户:

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.如果这不起作用,请尝试运行which mysql以查看您的 mysql 安装位置,然后将上面命令中的/usr/local/mysql/替换为“bin”目录之前的内容。

For example, on my system which mysql produces the following output:例如,在我which mysql产生以下输出:

/usr/local/mysql/bin/mysql

so my path is /usr/local/mysql/所以我的路径是/usr/local/mysql/

On CentOS/RedHat, you should do the same thing on a different path:在 CentOS/RedHat 上,你应该在不同的路径上做同样的事情:

chown -R mysql:mysql /data/mysql/
chmod -R 755 /data/mysql/
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.我可以确认这两个 chmod 语句对我有用(Webmin 没有看到数据库,也没有显示表)但是我不确定为什么在用 MySQL 设置了大约两打服务器(Centos)之后我必须这样做过去几年。

osx high sierra use the following command solves the issue: osx high sierra 使用以下命令解决问题:

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

if you installed mariadb using homebrew you can run the following the command for OS X如果你使用 homebrew 安装了 mariadb,你可以为 OS X 运行以下命令

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL 来自 AWS 的错误 Python Lambda 客户端 (2004 (HY000):无法创建 TCP/IP 套接字 (97)) - MySQL Error from AWS Python Lambda Client (2004 (HY000): Can't create TCP/IP socket (97)) 错误1(HY000):无法创建/写入文件'./scraping/db.opt'(错误代码:2) - ERROR 1 (HY000): Can't create/write to file './scraping/db.opt' (Errcode: 2) mysql.connector.errors.DatabaseError: 2003 (HY000): 无法连接到“127.0.0.1”上的 MySQL 服务器 (111) - mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111) 为什么 Python/Django 不会在 Mysql 上引发异常:ERROR 1205 (HY000): Lock wait timeout exceeded - Why Python/Django does not raise exception on Mysql: ERROR 1205 (HY000): Lock wait timeout exceeded pyodbc.Error:('HY000','驱动程序未提供错误!') - pyodbc.Error: ('HY000', 'The driver did not supply an error!') pyodbc MERGE INTO 错误:HY000:驱动程序未提供错误 - pyodbc MERGE INTO error: HY000: The driver did not supply an error (Python,MySQL)数据库错误:2003(HY000):无法连接到“196.xxx.xxx.xxx:3306”上的 MySQL 服务器(113) - (Pythin , MySQL) DatabaseError: 2003 (HY000): Can't connect to MySQL server on '196.xxx.xxx.xxx:3306' (113) mysql.connector.errors.DatabaseError:2003(HY000):无法连接到“本地主机”(111)上的 MySQL 服务器。 Flask 应用程序 - mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on 'localhost' (111). Flask app 解决循环程序中的“ERROR 2006 (HY000): MySQL server has gone away”(mysql-connector-python) - Solving “ERROR 2006 (HY000): MySQL server has gone away" in cyclical programs (mysql-connector-python) 为什么我收到错误 pyodbc.Error: ('HY000', '驱动程序没有提供错误!') - Why I receive error pyodbc.Error: ('HY000', 'The driver did not supply an error!')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM