Score:0

Server disk full, Mysql service can't start, how can i shrink the database?

ru flag

I'm currently having a major issue. VPS disk is full, mysql database grew unexpectedly, and can't buy more space from the hosting because it's already maxed out.

The mysql service can't start anymore because of storage space.

Is there any way I could execute queries on the database with the service off? But I guess it would require some third party tools, and the space on the server doesn't permit that. If I'm not mistaken, even if i delete some old data from the database, it won't shrink anyway.

I can't even download the entire database files on my computer and try to rebuild it there, because it's so huge I don't have any drive where it could fit.

What options I have now? Does anyone have any idea about what i could do next?

in flag
Delete other files so you get some space, try to cleanup index etc. Maybe a question better suited for dba.stackexchange.com
ua flag
What does `df` say?
Score:1
ng flag

MySQL doesn't run as root, so you probably still have 'reserved' free space. You can reclaim that: tune2fs -m 0 /dev/whatever.

You didn't say what OS you have, but there is probably some space you can free up elsewhere. If you have Ubuntu, try apt clean. Remove log files from /var/log/*, etc.

If you still can install something, install ncdu and do ncdu -x / to give you an easy overview of what to delete.

Also, a trick I often do, is have a dummy file of a few hundred MBs somewhere, that can be removed if you run into this situation. That, and monitoring of course.

Once you do have space, you're going to have to run OPTIMIZE TABLE on the offending table. However, this will cause a recreate, so you need extra space for that. Also, it requires running with innodb_file_per_table, which is the default nowadays.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.