1.首先声明我用的电脑是mac,网上搜索到的关于linux的修复方法我用不了.
2.我不是直接下载的mysql,我是用的XAMPP里面的mysql.
我之前只是重启过一次电脑,之后出现了这样的错误.
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 27
Server version: 10.1.10-MariaDB Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use lab6
Database changed
MariaDB [lab6]> show tables;
ERROR 1018 (HY000): Can't read dir of './lab6/' (errno: 13 "Permission denied")
根据楼上的提示成功的解决了问题,把解决方法留在这里,希望别人碰到同样的问题也能有所帮助.
看完楼上的回答我想到的是如何找到mysql的目录(我确实不知道那个目录在哪里),一番搜索之后发现可以在mysql中输入语句
show global variables like "%datadir%";
即可,得到了mysql的文件地址为/Applications/XAMPP/xamppfiles/var/mysql/
.然后打开终端cd 中进入那个目录 :
cd /Applications/XAMPP/xamppfiles/var/mysql/
, 然后cd ..
退回上一层目录之后,ls -l
查看了一下mysql的属主,发现确实不对劲,于是chown -R mysql:mysql /Applications/XAMPP/xamppfiles/var/mysql/
成功解决.
重启电脑后,发生的。重启之前是否安装或者更新了什么东西?在看看MYSQL目录的属主和属组,是否更变!改回去即可!