MySQL 找不到文件:'./ci/users.frm'(错误号:13)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6443428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:18:00  来源:igfitidea点击:

Can't find file: './ci/users.frm' (errno: 13)

mysqlubuntupermissions

提问by aTei

I installed LAMP on Ubuntu 11.04 and copy project from Windows. PHP directory (/ci/) to var/www/ and MySQL project directory (/ci/) to var/lib/mysql/

我在 Ubuntu 11.04 上安装了 LAMP 并从 Windows 复制项目。PHP 目录 (/ci/) 到 var/www/ 和 MySQL 项目目录 (/ci/) 到 var/lib/mysql/

Full text of error that i get:

我得到的错误全文:

A Database Error Occurred

    Error Number: 1017
    Can't find file: './ci/users.frm' (errno: 13)
    SELECT COUNT(*) AS `numrows` FROM (`users`) WHERE `email` = '[email protected]'

I googled that its permission problem, but don't know what do next.

我在谷歌上搜索了它的权限问题,但不知道下一步该怎么做。

Log from /var/log/mysql/error.log:

    110622 19:27:21 [ERROR] /usr/sbin/mysqld: Can't find file: './ci/users.frm' (errno: 13)

回答by Brent Baisley

Permissions problem meaning the permissions on the file. MySQL probably can't read it. Just change the owner and group to mysql and it should work.

权限问题意味着文件的权限。MySQL 可能无法读取它。只需将所有者和组更改为 mysql 就可以了。

chown mysql:mysql /var/lib/mysql/ci/*

回答by Simon Wheatley

As well as the files being readable by the MySQL user, the directorycontaining the .MYIfiles needs to be read, write and executable by the MySQL user. On my system this was achieved by:

除了 MySQL 用户可以读取的文件外,包含这些文件的目录也.MYI需要 MySQL 用户读取、写入和执行。在我的系统上,这是通过以下方式实现的:

chown -R mysql:mysql /var/lib/mysql/dbname
chmod -R 660 /var/lib/mysql/dbname
chown mysql:mysql /var/lib/mysql/dbname
chmod 700 /var/lib/mysql/dbname

回答by lowtrak

This is an old topic, but I didn't find anything that worked for me so for anyone running into the same problem, yet the above file permission suggestions still don't change the "Can't find file" errors, here's what worked for me and my particular issue.

这是一个老话题,但我没有找到任何对我有用的东西,所以对于遇到同样问题的任何人,但上述文件权限建议仍然没有改变“找不到文件”错误,这是有效的对于我和我的特定问题。

I was doing a rescue from one CentOS server to another using a recovery image, which had a different OS than the original OS and the original filesystem was mounted on a temporary dir. While I had access to the original /var/lib/mysql files, I didn't have access to the mysql admin or dump utilities, which requires the server to be running anyway (it's not automatically included when doing a recovery from a read-only image). Backups were a week old and I wanted to see if I could get the most recent data possible.

我正在使用恢复映像从一台 CentOS 服务器救援到另一台 CentOS 服务器,该恢复映像的操作系统与原始操作系统不同,并且原始文件系统安装在临时目录中。虽然我可以访问原始的 /var/lib/mysql 文件,但我无权访问 mysql admin 或 dump 实用程序,这要求服务器无论如何都在运行(从读取进行恢复时不会自动包含它)只有图像)。备份是一周前的,我想看看我是否可以获得最新的数据。

Changing the standard file permissions on these still kept giving "Can't find file" for nearly all of the database tables, however I could see that the tables were there. Turns out it was related to SELinux context on the files I had moved over using rysnc. All of the rescued dirs and files looked like this:

更改这些的标准文件权限仍然为几乎所有数据库表提供“找不到文件”,但是我可以看到这些表在那里。原来它与我使用 rysnc 移动的文件上的 SELinux 上下文有关。所有获救的目录和文件如下所示:

$ ls -alZ
drwx------. mysql mysql unconfined_u:object_r:admin_home_t:s0 somedb_dev
drwx------. mysql mysql unconfined_u:object_r:admin_home_t:s0 somedb_local
drwx------. mysql mysql unconfined_u:object_r:admin_home_t:s0 somedb_production
drwx------. mysql mysql unconfined_u:object_r:admin_home_t:s0 somedb_staging

The -Z flag notes the security context of files and dirs. Notice the unconfined_u and admin_home_t context. These are different from what they should be:

-Z 标志指出文件和目录的安全上下文。注意 unconfined_u 和 admin_home_t 上下文。这些与它们应有的不同:

drwx------. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql

Changing these database files to the proper context solved the problem and gave proper access to mysqld using the chcon command:

将这些数据库文件更改为正确的上下文解决了问题,并使用 chcon 命令正确访问了 mysqld:

$ chcon -R -u system_u -t mysqld_db_t somedb_*

This changed all my custom databases to the proper SELinux context and the files could now be recognized by mysqld. I recommend running the chcon commad while the database server is not active, just as a precaution.

这将我所有的自定义数据库更改为正确的 SELinux 上下文,并且文件现在可以被 mysqld 识别。我建议在数据库服务器不活动时运行 chcon 命令,作为预防措施。

Hope that helps someone running into the same problem I had! Of course, you can turn off SELinux temporarily to test if this is fact this issue, but I didn't want turning off SELinux as a permanent solution.

希望能帮助遇到同样问题的人!当然,你可以暂时关闭 SELinux 来测试这是否是这个问题的事实,但我不想关闭 SELinux 作为永久解决方案。

回答by Darwayne

This error also occurs if the table is not in the database; so if you changed permissions of the directory and are still running into issues check your database and make sure the table is there.

如果表不在数据库中,也会出现此错误;因此,如果您更改了目录的权限并且仍然遇到问题,请检查您的数据库并确保该表在那里。

So let's say you got an error like the OP:

因此,假设您遇到了类似 OP 的错误:

Can't find file: './ci/users.frm'

Can't find file: './ci/users.frm'

ciis the database name

ci是数据库名称

usersis the table name

users是表名

So in this case if you changed permissions and still had this issue you would verify that the userstable is in the cidatabase.

因此,在这种情况下,如果您更改了权限但仍然存在此问题,您将验证users表是否在ci数据库中。

回答by GTodorov

@Brent Baisley It does work in XAMPP for Linux, but the location is different.

@Brent Baisley 它确实适用于 Linux 的 XAMPP,但位置不同。

I did upgrade the Kernel today to fix the new Linux “Dirty Cow” Vulnerability (CVE-2016-5195). After the reboot I got the 'frm' permission error too.

我今天确实升级了内核以修复新的 Linux “Dirty Cow”漏洞 (CVE-2016-5195)。重新启动后,我也收到了“frm”权限错误。

So, if you get the following error:

因此,如果您收到以下错误:

Can't find file: 'yourtablename.frm' (errno: 13 - Permission denied) SQL query :...

You can do:

你可以做:

chown mysql:mysql /opt/lampp/var/mysql/yourDBname/*.frm

This will resolve your issue.

这将解决您的问题。

If you'd like to check, if your permission to any of the files has been modified before you execute the permission change, do:

如果您想检查在执行权限更改之前您对任何文件的权限是否已被修改,请执行以下操作:

ls -l /opt/lampp/var/mysql/yourDBname/*.frm

Hope that helps someone.

希望能帮助某人。

回答by Rick

I followed this steps:

我按照以下步骤操作:

  • Stop the mysql service.

  • Modify the my.cnf line datadir to my custom location.

  • Deleted all the files ib_data* , ib_logfile* in our new custom location

  • Change the permissions of the entire folder with your sentence: chown mysql:mysql -R /custom_location/mysql/*

  • Start again the mysql service.

  • 停止mysql服务。

  • 将 my.cnf 行 datadir 修改为我的自定义位置。

  • 删除了我们新自定义位置中的所有文件 ib_data* , ib_logfile*

  • 用你的一句话改变整个文件夹的权限:chown mysql:mysql -R /custom_location/mysql/*

  • 再次启动mysql服务。

It works!!

有用!!

Thanks

谢谢