Fixing MySQL error 1036: table is read only

Recently I undertook formatting my hard drive, and therefore had to do some backups and restoring of my data including my local mysql databases.

For this I used rsync to back up my /var directory. The Problem is that the drive storeing the backed up files was running a FAT32 partion. This means all file owner ship was lost.

When I restored my files I was not able to access mysql databses getting the 1036 error.

After a few searches I found this article. It had a reason but no fix for people. So here is my extention of that article.

To see the problem

From the command line on a standard *nix install one can view who owns the files: by typing:

ls -l /var/lib/mysql

your results might look like:

total 20544-rw-r--r-- 1 mysql mysql        0 2010-05-02 15:57 debian-5.1.flag
drwxr-xr-x 2 root root	    12288 2010-05-04 15:03 drupal
-rw-rw---- 1 mysql mysql        6 2010-05-04 15:04 dublin.pid
-rw-rw---- 1 mysql mysql      125 2010-05-03 12:52 dublin-relay-bin.000001
-rw-rw---- 1 mysql mysql      125 2010-05-04 15:04 dublin-relay-bin.000002
-rw-rw---- 1 mysql mysql      106 2010-05-04 15:04 dublin-relay-bin.000003
-rw-rw---- 1 mysql mysql       78 2010-05-04 15:04 dublin-relay-bin.index
-rw-rw---- 1 mysql mysql 10485760 2010-05-04 15:04 ibdata1
-rw-rw---- 1 mysql mysql  5242880 2010-05-04 15:04 ib_logfile0
-rw-rw---- 1 mysql mysql  5242880 2010-05-02 15:57 ib_logfile1
-rw-rw---- 1 mysql mysql       30 2010-05-04 15:04 master.info
drwxr-xr-x 2 root root	     4096 2010-05-04 15:03 mysql
-rw-rw---- 1 mysql mysql        6 2010-05-02 15:57 mysql_upgrade_info
-rw-rw---- 1 mysql mysql       31 2010-05-04 15:04 relay-log.info
drwxr-xr-x 2 root root	    16384 2010-05-04 15:03 zc139

If in some of the output of the, ls -l has the pattern "root root", this means that the unix user root owns these files and that mysql can not modify them. This is what is causeing the Read Only issue.

The Fix:

One needs super user privs to do this, most commonly sudo is uesed to acheve this.

To Change the owner of the files.

sudo chown -R mysql:mysql /var/lib/mysql 

Reboot Mysql so that the changes are detected.

sudo service mysql restart

 


From there it should work.

 

 

 

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 9 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Recent Tweets

I search every day, but I rarely google — 36 weeks 9 hours ago
@rickmanelius http://t.co/NrZB8Z3z the tab issue is helped a bit — 36 weeks 1 day ago
note to self, one has to use variable replacements when adding serialized data to a table using db_query() #drupal — 36 weeks 1 day ago
there are times, when saying "I told you so" makes me more angry than satified — 36 weeks 5 days ago
thanks for the update @JacobSingh36 weeks 6 days ago
for the forst time I did not have to restart firefox to add a plugin! #AchievementUnlocked — 37 weeks 3 hours ago
@ACTVMedia I clicked on on the link expecting an awesome talking car, and then I had to learn something. — 37 weeks 3 hours ago
@r_kois @rickmanelius I wish there was a query language for finding layers — 37 weeks 5 hours ago
@greggles I would throw confettie but I have to run nad upgrade — 37 weeks 6 hours ago
looking at the feesability of scraping a frontpage 4 generated html site into Drupal 7 — 37 weeks 7 hours ago

©2009 Sanguis Development. 462 North King Street, Northampton MA 01060
Phone: (413) 570-0659

AIM: joshbeaureg || Skype: sanguisdex
Syndicate content