Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I used MAMP on my local machine to make a little site with a mysql database. I moved all the site files over the to server. Great.

The name of my database is roster and it has one table called users. I copied the 'roster' folder which contains the following files:

db.opt
users.frm
users.MYD
users.MYI

I put the 'roster' folder in the mysql directory. I run the following:

<?php
$db = mysql_connect("localhost","username","password") or die ('Fail message1');
mysql_select_db("roster") or die("Fail message2");
?>

No error. Awesome. But when I run the following:

$query = "SELECT last_name, first_name, u_name, skype_id, primary_location FROM users";

$result = mysql_query($query)or die('query error'.mysql_error());

Then I receive the following error:

query errorCan't find file: './roster/users.frm' (errno: 13)

Furthermore, when I login to the server and login to mysql. I see the database and table:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| phones_db          |
| roster             |
+--------------------+
4 rows in set (0.00 sec)

mysql> use roster;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;
+------------------+
| Tables_in_roster |
+------------------+
| users            |
+------------------+
1 row in set (0.00 sec)

mysql> select * from users;
ERROR 1017 (HY000): Can't find file: './roster/users.frm' (errno: 13)
mysql> 

I checked the 'roster' folder and it contains the four files mentioned at the beginning of this post. The file is where it supposed to be, right? Did I move the database wrong? What gives? Any ideas?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

PROBLEM

You have a file permission issue.

The INFORMATION_SCHEMA database will not notice when doing just show tables; because it will scan for the .frm's existence. It's when the storage engine attempts to access the physical files (.MYD and .MYI') that mysqld will complain. All physical files of any table must havemysqlas its owner. When the error saysCan't find file: './roster/users.frm' (errno: 13)`, it really means it cannot find the table's physical files with proper file permissions.

SOLUTION

Change the owner of the roster folder and its contents to mysql.

GIVE IT A TRY !!!

share|improve this answer
1  
+1 Also disable SELinux. SELinux frequently reports errors in file locations, permissions, etc. as "file not found." –  Bill Karwin Oct 1 '13 at 17:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.