mysql error dealing with permissions
I was dealing with directly writing .MYD, .MYI and .frm files to my mysql data directory today and was experience the following problems when trying to access it:
I was getting the error “Can’t find file {database}/{table}.frm (errno: 13)”. I looked in /usr/include/asm/errno.h and it showed that errno: 13 was “Permission denied”.
At first the files were chmod’ed 644 with user rdehler and group users. I made all of the database files chmod’ed 660 with user mysql and group mysql and restarted the mysql server with /etc/init.d/mysql restart. After doing this, I logged in and tried to select a table when I got this message “Didn’t find any fields in table {tablename}”, one message for every table in the database. After scratching my head a little bit, I decided to make all of the files 770, restarted the mysql server and it worked.
For future reference I created a script that does it for me whenever I have to copy over files:
#!/bin/bash -f
echo Stopping the mysql server
/etc/init.d/mysql stop
echo Setting permissions for graphics folder
`chmod -R 770 /var/lib/mysql/{database directory}`
echo Changing owner of graphics databases
`chown -R mysql /var/lib/mysql/{database directory}`
echo Changing group of graphics databases
`chgrp -R mysql /var/lib/mysql/{database directory}`
echo Starting the mysql server
/etc/init.d/mysql start
An easier solution to having to do this everytime? You can simply import it in while mysql is running. However this is only if you have a .sql file that you can import rather than the .MYD, .MYI and .frm files directly.
