Table is 'read only'

后端 未结 10 1249
旧时难觅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:27

    who owns /var/db/mysql and what group are they in, should be mysql:mysql. you'll also need to restart mysql for changes to take affect

    also check that the currently logged in user had GRANT access to update

    0 讨论(0)
  • 2020-11-29 12:29

    One other way to receive this error is to create your table with a "Like" statement and use as source a merged table. That way the newly create table is read-only and can't "receive" any new records.

    so

    CREATE TABLE ic.icdrs_kw37 LIKE ic.icdrs ... #<- a merged table.
    

    then:

    REPLACE INTO ic.icdrs_kw37 ...  # -> "Table is read-only"
    

    bug or feature?

    0 讨论(0)
  • 2020-11-29 12:30

    You should change owner to MYSQL:MYSQL.

    Use this command: chown -Rf mysql:mysql /var/lib/mysql/DBNAME

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-29 12:36

    In my case, mysql config file had innodb_force_recovery = 1. Commenting that out solved the issue. Hope it helps someone.

    0 讨论(0)
  • 2020-11-29 12:39

    On windows I use Xampp server I comment the line in my.ini innodb_force_recovery = 1 to #innodb_force_recovery = 1 the problem resolved

    0 讨论(0)
提交回复
热议问题