mariadb – What queries to run when database is hanging/crashing?

So you left your database running for days, weeks. Then suddenly starts hanging.

You manage to open a connection and want to run queries and save the data to disk to look at later and see what happened, statistics about possible performance issues, general stats, etc.

What queries would you run ?

I ask because I’m suffering from this issue. My database run fine for days then it suddenly crashes. I think a answer describing useful queries to run and save the data could help a lot of people in situations like this