Question

MySQL keeps crashing - Error establishing a database connection

Posted August 20, 2021 366 views
MySQLWordPress

I had installed ubuntu 20.04 on 15$ monthly/ 2GB/2CPU and I have a problem with my MySQL server that keeps crashing.
I will list below the last lines from the myqsl/error.log file.
I can’t figure out what the problem/error is in order to fix it.

2021-08-20T15:35:54.676626Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26-0ubuntu0.20.04.2) starting as process 47806
2021-08-20T15:35:54.715129Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-08-20T15:35:55.518494Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-08-20T15:35:55.889880Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2021-08-20T15:35:55.910933Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2021-08-20T15:35:55.968155Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-08-20T15:35:55.968416Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-08-20T15:35:55.972738Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-08-20T15:35:55.973735Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-08-20T15:35:56.049092Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-08-20T15:35:56.049283Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.26-0ubuntu0.20.04.2'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
2021-08-20T15:35:56.358145Z 8 [ERROR] [MY-013134] [Server] Table './database_name/wprd_postmeta' is marked as crashed and should be repaired
2021-08-20T15:35:56.367954Z 8 [Warning] [MY-010756] [Server] Checking table:   './database_name/wprd_postmeta'
2021-08-20T15:35:56.396138Z 10 [ERROR] [MY-013134] [Server] Table './database_name/wprd_options' is marked as crashed and should be repaired
2021-08-20T15:35:56.397423Z 10 [Warning] [MY-010756] [Server] Checking table:   './database_name/wprd_options'
2021-08-20T15:35:56.759102Z 9 [ERROR] [MY-013134] [Server] Table './database_name/wprd_ahm_sessions' is marked as crashed and should be repaired
2021-08-20T15:35:56.759734Z 9 [Warning] [MY-010756] [Server] Checking table:   './database_name/wprd_ahm_sessions'
2021-08-20T15:35:57.341553Z 11 [ERROR] [MY-013134] [Server] Table './database_name/wprd_usermeta' is marked as crashed and should be repaired
2021-08-20T15:35:57.342417Z 11 [Warning] [MY-010756] [Server] Checking table:   './database_name/wprd_usermeta'
2021-08-20T15:36:05.715122Z 12 [ERROR] [MY-013134] [Server] Table './database_name/wprd_ahm_download_stats' is marked as crashed and should be repaired
2021-08-20T15:36:05.720212Z 12 [Warning] [MY-010756] [Server] Checking table:   './database_name/wprd_ahm_download_stats'

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello, @kislaygupta65

In order to repair the crashed tables you can use the mysqlchek command:

  • mysqlchek -r database_name

You can first check the MySQL configuration and make sure that the values and memory assigned to the buffer_pool are not higher than they should be as this is likely to cause issues like this.

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget http://mysqltuner.pl/ -O mysqltuner.pl
  • Then execute it:
perl mysqltuner.pl

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

https://www.digitalocean.com/products/managed-databases-mysql/

This was mini tutorial was posted from bobbyiliev in this question in our community: https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

Hope that this helps!
Regards,
Alex