Summary of Table is read only solutions in mysql

  • 2020-05-15 02:20:44
  • OfStack

If the database is in use, some class problems suddenly appear
Just execute the following command under Linux, of course you need to find your mysql directory

In the linux
 
/usr/local/mysql/bin/mysqladmin -u root -p flush-tables 

In the windows
You can perform lush-tables in cmd
The fix table can also be modified directly in phpmyadmin

If you are importing and restoring data
, so all the table files under the database folder chmod into 777, chown into "_mysql", but this time the problem is more serious, drupal into table crached. No way, Google immediately, found that the solution is actually quite easy.
First, find the location of mysqladmin, 1 is usually under mysql/bin, then run 1 and command:
 
./mysqladmin -u root -p flush-tables 

After entering the password of root account, it will be ready immediately without any prompt. Open drupal again, and the 1 cut is normal.
This time, the correct permissions for the database files were also found: data database folder 700, table files 660, all files should be owned by mysql.

The following is also a problem with moving from the window database to the linux server

1 Discuz forum, the original frame under windows, using the GBK code, MYSQL version is 5.0.
Now you need to move to Linux. I originally suggested using the mysqldump export method, but my colleagues wanted to directly use the database directory under the data directory.

Try moving the directory first, creating the database on the new server, and then moving the old directory over.

In mysql, Select and the like are normal, but in the web application it says: Table 'cdb_posts' is read only

Change the user and group of the database directory to mysql, and add 777 permissions, or 1 prompt.

The program USES the root connection, which is also a 1 - like prompt.

If you want to check 1 with myisamchk, read only is also indicated.

Finally found the solution: here http: / / www mysqltalk. org/re - the - table is - read - only - vt154092. html

reference
I just encountered a similar problem on one of my production servers
this morning. (I'm still investigating the cause.) After doing a
quick bit of Google-searching, this solved my problem:

mysqladmin -u < username > -p flush-tables

By the way: All directories in /var/lib/mysql should have 700
permissions (owned my the mysql user) and everything within those
directories should be 660 (owned by the mysql user and mysql group).

After running flush-tables, read only problem solved :)

Then I found that there were still some problems with the data structure and content. Checking the error with myisamchk was invalid, and then using mysqldump to guide, but I still encountered a lot of problems. Due to the large database to be transferred, it took a long time, and finally it did not continue.
After knowing some knowledge points, record 1:

mysql5 exports the Settings of default-charact, but mysql4 does not support it. skip-opt parameters need to be added, such as:
mysqldump -uroot -p --default-character-set=gbk -skip-opt databse > hx.sql
Reference article: Mysql database character set conversion

Finally, I found a server of mysql5, exported it with mysqldump, imported it with mysql, and succeeded once!
Found 1 table exported with mysqldump, 300w multiple records, used for just over 4 minutes, processing 1w multiple records per second, quick! It took about 10 minutes to import, and several thousand per second was fast :)

Related articles: