Table is 'read only'

后端 未结 10 1288
旧时难觅i
旧时难觅i 2020-11-29 12:07

When I want to execute an update query on my table I got an error saying:

1036 - Table data is read only.

10条回答
  •  离开以前
    2020-11-29 12:32

    My situation is everytime I needed to edit "innodb_force_recovery = 1" in my.ini to force mysql to start, and the error log showed some error said:

    Attempted to open a previously opened tablespace. Previous tablespace mysql/innodb_table_stats uses space ID: 1 at filepath: .\mysql\innodb_table_stats.ibd. Cannot open tablespace profile/profile_commentmeta which uses space ID: 1 at filepath: .\profile\profile_commentmeta.ibd

    I didn't know why this file was not able to open and it caused so many other"table read only" problems to other databases too.

    So here is how I fixed this problem in a simple way without hurting other files.

    1 First of all, make sure if you add innodb_force_recovery = 1 below [mysqld] in my.ini file, and it is working, under path: X:\xampp\mysql\bin\my.ini

    2 Then next step, export all the databases through localhost/phpmyadmin under the export tab, and store them somewhere, like this:

    3 comment out the data filefolder to data-bak, then create a new data filefolder,

    4 Next step, import all .sql database back from phpmyadmin panel, please also copy phpmyadmin filefolder from the old data-bak filefolder to the new data filefolder. If any file is necessary, go back to data-bak filefolder to copy and paste.

    Now all fixed and done, don't need to force mysql to start everytime. Hope this also works for you.

提交回复
热议问题