LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-08-2008, 11:47 AM   #1
brianpbarnes
Member
 
Registered: Dec 2005
Posts: 143

Rep: Reputation: 15
Mysterious MySQL Table 'name' is read only permission error problem.


Hi,
I had a system disk die on an old Suse server. I never got it to boot again. I had a number of MySQL databases on another disk and I managed to save them, but I have only the .frm, .MYD and .MYI files, not a proper backup or mysqldump.

For my new Suse replacement server, I hacked them in:
1) make a directory with the name of the database in /var/lib/mysql
2) copy the .frm file to this new directory
3) make a ln -s from the .MYD and .MYI files to this new directory.
4) Set ownership to me and group to mysql for new dir and all files
5) Give mysql rw permissions on all files
6) restart MySQL and it magically sees all databases and can update them.

I did exactly the same thing on my new Ubuntu 8.04 workstation. I want to work on some of the large databases locally. I have given unlimited 777 permissions to every file and directory and made mysql the group for everything and it still complains about "Table 'all' is read only".

I have a firm rule about separating data from system. I do a partition backup of "/dev/sdb2" which is mounted on "/" and get everything except for pictures, music, videos, etc. which I backup with tar or simple file copies. One minor exception I make is for .frm files (sort of system files) and tiny .MYI and .MYD files which are neglibibly tiny. All large data files go on a large data disk, not /.

This way, I can compress my entire system image and fit it all on one DVD with Mondo.

I have set the least restrictive permissions on everything owned by the PIC database:
brianp@godzilla2:/var/lib/mysql/pic$ ll /var/lib/mysql
total 21M
-rw-r--r-- 1 mysql mysql 0 2008-10-06 13:38 debian-5.0.flag
-rw-rw---- 1 mysql mysql 10M 2008-10-08 10:01 ibdata1
-rw-rw---- 1 mysql mysql 5.0M 2008-10-08 10:12 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M 2008-09-26 09:17 ib_logfile1
drwxr-xr-x 2 mysql mysql 4.0K 2008-10-06 13:38 mysql
-rw------- 1 mysql mysql 7 2008-09-26 09:17 mysql_upgrade_info
drwxrwxrwx 2 brianp mysql 4.0K 2008-10-07 17:28 pic

The "pic" datbase is the one I am trying to get to. Its 777 permissions.

In the pic database directory, all of the .frm files are plain files, not links and again have fully open permissions:
brianp@godzilla2:/var/lib/mysql/pic$ ll /var/lib/mysql/pic
total 96K
-rwxrwxrwx 1 brianp mysql 8.7K 2008-10-07 17:28 attr.frm
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 attr.MYD -> /r5/mysql/pic/attr.MYD
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 attr.MYI -> /r5/mysql/pic/attr.MYI
-rwxrwxrwx 1 brianp mysql 8.7K 2008-10-07 17:28 disc.frm
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 disc.MYD -> /r5/mysql/pic/disc.MYD
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 disc.MYI -> /r5/mysql/pic/disc.MYI
-rwxrwxrwx 1 brianp mysql 9.0K 2008-10-07 17:28 exif.frm
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 exif.MYD -> /r5/mysql/pic/exif.MYD
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 exif.MYI -> /r5/mysql/pic/exif.MYI
-rwxrwxrwx 1 brianp mysql 8.7K 2008-10-07 17:28 file.frm
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 file.MYD -> /r5/mysql/pic/file.MYD
lrwxrwxrwx 1 brianp mysql 22 2008-10-07 17:28 file.MYI -> /r5/mysql/pic/file.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 keyword.frm
lrwxrwxrwx 1 brianp mysql 25 2008-10-07 17:28 keyword.MYD -> /r5/mysql/pic/keyword.MYD
lrwxrwxrwx 1 brianp mysql 25 2008-10-07 17:28 keyword.MYI -> /r5/mysql/pic/keyword.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 thumbnail.frm
lrwxrwxrwx 1 brianp mysql 27 2008-10-07 17:28 thumbnail.MYD -> /r5/mysql/pic/thumbnail.MYD
lrwxrwxrwx 1 brianp mysql 27 2008-10-07 17:28 thumbnail.MYI -> /r5/mysql/pic/thumbnail.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 toenail_dvd.frm
lrwxrwxrwx 1 brianp mysql 29 2008-10-07 17:28 toenail_dvd.MYD -> /r5/mysql/pic/toenail_dvd.MYD
lrwxrwxrwx 1 brianp mysql 29 2008-10-07 17:28 toenail_dvd.MYI -> /r5/mysql/pic/toenail_dvd.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 toenail_hd.frm
lrwxrwxrwx 1 brianp mysql 28 2008-10-07 17:28 toenail_hd.MYD -> /r5/mysql/pic/toenail_hd.MYD
lrwxrwxrwx 1 brianp mysql 28 2008-10-07 17:28 toenail_hd.MYI -> /r5/mysql/pic/toenail_hd.MYI

Going through to the links to the .MYD and .MYI files, they too have 777 permissions:
brianp@godzilla2:/var/lib/mysql/pic$ ll -L /var/lib/mysql/pic
total 30G
-rwxrwxrwx 1 brianp mysql 8.7K 2008-10-07 17:28 attr.frm
-rwxrwxrwx 1 brianp mysql 2.3M 2007-09-26 19:42 attr.MYD
-rwxrwxrwx 1 brianp mysql 3.1M 2007-09-28 09:53 attr.MYI
-rwxrwxrwx 1 brianp mysql 8.7K 2008-10-07 17:28 disc.frm
-rwxrwxrwx 1 brianp mysql 1.4M 2007-09-26 19:42 disc.MYD
-rwxrwxrwx 1 brianp mysql 4.0K 2007-09-28 09:53 disc.MYI
-rwxrwxrwx 1 brianp mysql 9.0K 2008-10-07 17:28 exif.frm
-rwxrwxrwx 1 brianp mysql 4.2M 2007-09-26 19:51 exif.MYD
-rwxrwxrwx 1 brianp mysql 617K 2007-09-28 09:53 exif.MYI
-rwxrwxrwx 1 brianp mysql 8.7K 2008-10-07 17:28 file.frm
-rwxrwxrwx 1 brianp mysql 5.7M 2007-09-26 19:51 file.MYD
-rwxrwxrwx 1 brianp mysql 5.0M 2007-09-28 09:53 file.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 keyword.frm
-rwxrwxrwx 1 brianp mysql 39K 2007-09-26 19:51 keyword.MYD
-rwxrwxrwx 1 brianp mysql 22K 2007-09-28 09:53 keyword.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 thumbnail.frm
-rwxrwxrwx 1 brianp mysql 1.1G 2007-09-26 19:51 thumbnail.MYD
-rwxrwxrwx 1 brianp mysql 431K 2007-09-28 09:53 thumbnail.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 toenail_dvd.frm
-rwxrwxrwx 1 brianp mysql 25G 2007-09-26 19:51 toenail_dvd.MYD
-rwxrwxrwx 1 brianp mysql 1007K 2007-09-28 10:01 toenail_dvd.MYI
-rwxrwxrwx 1 brianp mysql 8.5K 2008-10-07 17:28 toenail_hd.frm
-rwxrwxrwx 1 brianp mysql 3.4G 2007-09-26 19:43 toenail_hd.MYD
-rwxrwxrwx 1 brianp mysql 71K 2007-09-28 10:02 toenail_hd.MYI

I have checked all of the directories leading up to the linked files:
brianp@godzilla2:/var/lib/mysql/pic$ ll / | grep r5
drwxrwxrwx 7 brianp root 4.0K 2008-10-08 10:46 r5

brianp@godzilla2:/var/lib/mysql/pic$ ll /r5
<snip>
drwxrwxrwx 7 brianp mysql 4.0K 2008-10-07 13:15 mysql

brianp@godzilla2:/var/lib/mysql/pic$ ll /r5/mysql/
<snip>
drwxrwxrwx 2 brianp mysql 4.0K 2008-10-07 12:28 pic

brianp@godzilla2:/var/lib/mysql/pic$ ll /r5/mysql/pic
total 30G
-rw-rw---- 1 brianp mysql 8.7K 2007-09-28 09:53 attr.frm
-rwxrwxrwx 1 brianp mysql 2.3M 2007-09-26 19:42 attr.MYD
-rwxrwxrwx 1 brianp mysql 3.1M 2007-09-28 09:53 attr.MYI
-rwxr--r-- 1 brianp brianp 65 2007-09-26 19:51 db.opt
-rw-rw---- 1 brianp mysql 8.7K 2007-09-26 19:42 disc.frm
-rwxrwxrwx 1 brianp mysql 1.4M 2007-09-26 19:42 disc.MYD
-rwxrwxrwx 1 brianp mysql 4.0K 2007-09-28 09:53 disc.MYI
-rw-rw---- 1 brianp mysql 9.0K 2007-09-26 19:51 exif.frm
-rwxrwxrwx 1 brianp mysql 4.2M 2007-09-26 19:51 exif.MYD
-rwxrwxrwx 1 brianp mysql 617K 2007-09-28 09:53 exif.MYI
-rw-rw---- 1 brianp mysql 8.7K 2007-09-28 09:53 file.frm
-rwxrwxrwx 1 brianp mysql 5.7M 2007-09-26 19:51 file.MYD
-rwxrwxrwx 1 brianp mysql 5.0M 2007-09-28 09:53 file.MYI
-rw-rw---- 1 brianp mysql 8.5K 2007-09-26 19:51 keyword.frm
-rwxrwxrwx 1 brianp mysql 39K 2007-09-26 19:51 keyword.MYD
-rwxrwxrwx 1 brianp mysql 22K 2007-09-28 09:53 keyword.MYI
-rw-rw---- 1 brianp mysql 8.5K 2007-09-26 19:51 thumbnail.frm
-rwxrwxrwx 1 brianp mysql 1.1G 2007-09-26 19:51 thumbnail.MYD
-rwxrwxrwx 1 brianp mysql 431K 2007-09-28 09:53 thumbnail.MYI
-rw-rw---- 1 brianp mysql 8.5K 2007-09-26 19:51 toenail_dvd.frm
-rwxrwxrwx 1 brianp mysql 25G 2007-09-26 19:51 toenail_dvd.MYD
-rwxrwxrwx 1 brianp mysql 1007K 2007-09-28 10:01 toenail_dvd.MYI
-rw-rw---- 1 brianp mysql 8.5K 2007-09-28 10:02 toenail_hd.frm
-rwxrwxrwx 1 brianp mysql 3.4G 2007-09-26 19:43 toenail_hd.MYD
-rwxrwxrwx 1 brianp mysql 71K 2007-09-28 10:02 toenail_hd.MYI


I have turned all permissions OFF 100% and mysql still can't see anything. Obviously, the "read only" error message it is giving me is not correct.

Does anybody have any ideas what it is really complaining about?

Thank you,

BrianP
 
Old 10-08-2008, 12:29 PM   #2
brianpbarnes
Member
 
Registered: Dec 2005
Posts: 143

Original Poster
Rep: Reputation: 15
apparmor is the culprit!

Hi,
Some funky, protect you from yourself service called apparmor is apparently the problem here. I once found it infesting a network interface and when I eradicated it, my network worked again.

Here's the recipe:
sudo vi /etc/apparmor.d/usr.sbin.mysqld
Add the line: /r5/mysql/** rwk,
The "/r5/mysql" is the large data disk and directory where I stashed my umpteen gigabyte .MYD and .MYI files which I linked to my new database directories in /var/lib/mysql. The "** rwk" I copied from the /var/lib/mysql entry without having any idea as to what it means. Use at your own risk.
(the ** means all-all files? Read Write and K???)

sudo /etc/init.d/apparmor restart
sudo /etc/init.d/mysql restart


Of all the servers I have running, only my printer and my database are "armored". As if somebody is going to steal my printer. One would have to think that Apache, Samba and SSH would be far better candidates for armoring than CUPS!

Again, this is for Ubuntu 8.04 running mysql installed from yast and trying to follow symbolic links to the raw data files.

Caveat DBA,

BrianP
 
Old 10-08-2008, 02:08 PM   #3
brianpbarnes
Member
 
Registered: Dec 2005
Posts: 143

Original Poster
Rep: Reputation: 15
An even better solution

Hi,
Now, I can actually read my symbolically linked data files, but I can not administer mysql. Mysqladmin gets permission denied writing my.cnf.

That's the last straw.

Try this:
From: https://help.ubuntu.com/community/AppArmor
brianp@godzilla2:/etc/mysql$ sudo /etc/init.d/apparmor stop
Unloading AppArmor profiles : done.
brianp@godzilla2:/etc/mysql$ sudo update-rc.d -f apparmor remove
Removing any system startup links for /etc/init.d/apparmor ...
/etc/rcS.d/S37apparmor

But wait! That's not even enough. /etc/mysql is owned by root.root. Running mysqladmin as me, I can't write there (and neither can mysql).

brianp@godzilla2:/etc/mysql$ sudo chown brianp.mysql .

Now, it actually works.

It looks like the ubuntu gang and the mysql gang need to get together to allow one to work with the other. Grrrrrrr!

BrianP
 
Old 10-08-2008, 02:12 PM   #4
Total-MAdMaN
Member
 
Registered: May 2008
Distribution: Gentoo
Posts: 306

Rep: Reputation: 34
Quote:
Originally Posted by brianpbarnes View Post
But wait! That's not even enough. /etc/mysql is owned by root.root.
Most, if not all, programs installed will be owned as root.
 
Old 10-09-2008, 09:41 AM   #5
brianpbarnes
Member
 
Registered: Dec 2005
Posts: 143

Original Poster
Rep: Reputation: 15
Owned by root? -- Sudo Voodoo?

Hi,

> Most, if not all, programs installed will be owned as root.

That's all well and good if it is handled in the correct way. The implementation blunder on the part of ubuntu is to make it impossible to actually use the LAMP tools they installed without performing brain surgery on their setup.

Can you imagine installing Firefox and not being able to set your network proxy? Running Thunderbird without being able to input your email address? Installed programs which are impossible for the user to configure are often completely useless.

They may need some sudo voodoo behind the scenes to make their os and their applications play well together.

My $0.02,

Brian
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySql: Table 'X' marked as read only Cyth Programming 10 07-12-2011 12:09 PM
FC4 Install error - cannot re-read partition table praveen_143 Fedora - Installation 0 12-28-2005 02:59 PM
Cannot read table of mounted filesystems: Input/output error k0ljat Linux - Software 1 09-18-2004 01:51 PM
Mysterious Read Only problem. ReiserFS. Flerbizky Linux - Software 3 08-26-2004 08:25 AM
mysql 'user' table read-only fuelinjection Linux - General 2 06-13-2004 09:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration