MySQL error 1036: table is read only

2019-02-16 22:45发布

问题:

When im trying to insert a record to the table using phpmyadmin it gives me

#1036 - Table 'sch_portfolio' is read only 

I saw in some articles they said that this could happen if the owner of this table is somthing other than mysql. so i set the owner as mysql and restart the server. Still im getting the same error. any help would be really appreciated. Thanks in advance

drwxrwxrwx 2 mysql mysql     4096 Jul 13 15:27 schooltap

回答1:

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

in order too Change the owner of the files.

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

Reboot Mysql for the changes

sudo service mysql restart

who owns sch_portfolio 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

The MySQL server is running as user mysql and not as the user I logged into it with. In order for it to access files that have user only rights they must be owned by user ‘mysql’ since that is what the server is running as. Make sure the folder and files used by mysql belong to the user ‘mysql’. These files are located in the /var/lib/mysql directory. The directory itself should also belong to ‘mysql’.



回答2:

Make sure you have not set innodb_force_recovery > 0 in my.cnf



回答3:

According to me, this is because of storage engine . If you select storage engine as MRG_MYISAM then that will make your table only readable, you can't insert data. So, select myisam as storage engine ..



回答4:

I suspect that in my case, this was caused by a hidden anti malware antivirus Bytefence (probably, it was bundled with something else). The problem was gone after uninstalling this antivirus.