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.
3 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Recent Tweets

New post: Green Web Site Hosting http://tinyurl.com/336wstt7 weeks 3 days ago
one can use git (unlike svn) over ssh_fs or ftp_fs but don't try it with the vim VCS plug in (still waiting) — 8 weeks 1 day ago
deleted over 3000 lines of extraneous code yesterday — 8 weeks 1 day ago
is doing a long needed complete merging of generousfashions.com custom files vs the most current from Zen Cart 1.3.9d — 8 weeks 1 day ago
New Portfolio Item : Northampton Beer & Winemaking Supplies http://tinyurl.com/2uot7xw beer-winemaking.com customer Drupal and UberCart — 8 weeks 4 days ago
New Portfolio item danieltrenner.com custom wordPress site t: daniel trenner :: tango http://tinyurl.com/2unxy8s8 weeks 4 days ago
just commented on @robwilkerson 's blog regarding the fix for a mutual git error at http://bit.ly/9iGmeg14 weeks 2 days ago
just made a screen case for a client that was havving trouble with my readme file — 15 weeks 11 hours ago
New post: Sangune Easy Embed Moving repository and Other Changes http://tinyurl.com/39jskhg16 weeks 1 day ago
Just wrote a readme in LaTeX. — 16 weeks 1 day ago

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

AIM: joshbeaureg || Skype: sanguisdex
Syndicate content