[英]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.