Dari salah satu client, load MySQL/MariaDB WordPress yang mereka gunakan sangat tinggi, CPU yang digunakan > 90%. Sebelum melakukan tuning dan berbagai fix, terlebih dahulu cek log dari webserver yang digunakan.
Pengguna nginx, pastikan server block memiliki
error_log /var/log/nginx/DOMAIN.com.error_log; access_log /var/log/nginx/DOMAIN.com.access_log;
lalu reload nginx
. Bila domain yang digunakan memiliki pengunjung ribuan, ubah bagian error_log menjadi error_log /var/log/nginx/DOMAIN.com.error_log crit
, agar nginx hanya menyimpan log kritikal, dan access_log off;
, untuk menonaktifkan access log bila anda sudah memiliki monitoring dari pihak ketiga.
Dilihat dari log yang muncul ada banyak Access denied for user 'username_here'@'localhost'
journalctl -u mariadb -f # output Jun 07 01:52:18 clusterjkt1.prod.DOMAIN.com mariadbd[3915361]: 2025-06-07 1:52:18 30519074 [Warning] Access denied for user 'username_here'@'localhost' (using password: YES) Jun 07 02:08:22 clusterjkt1.prod.DOMAIN.com mariadbd[3915361]: 2025-06-07 2:08:22 30519836 [Warning] Access denied for user 'username_here'@'localhost' (using password: YES)
user username_here
tidak ada di MariaDB.
Log nginx WordPress
tail -f /var/log/nginx/DOMAIN.com.access_log # output 1.2.3.4 - - [06/Jun/2025:14:19:45 +0700] "GET /wp-config-sample.php HTTP/2.0" 500 162 "-" "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36" "1.2.3.4"
ada ribuan file yang menargetkan /wp-config-sample.php
, bila dilihat isi dari file tersebut
<?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the installation. * You don't have to use the website, you can copy this file to "wp-config.php" * and fill in the values. * * This file contains the following configurations: * * * Database settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/ * * @package WordPress */ // ** Database settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'database_name_here' ); /** Database username */ define( 'DB_USER', 'username_here' ); /** Database password */ define( 'DB_PASSWORD', 'password_here' ); /** Database hostname */ define( 'DB_HOST', 'localhost' );
Coba akses langsung ke https://DOMAIN.com/wp-config-sample.php
, muncul halaman “Error establishing a database connection”
Tiap user/bot yang mengakses URL tersebut, WordPress akan mencoba menjalankan file tersebut. Hal ini yang menyebabkan database MariaDB overload. Dari sini sudah terlihat jelas penyebab utamanya, untuk solusinya pertama kita hapus file wp-config-sample.php
karena file tersebut tidak dipakai oleh WordPress, hanya sebagai contoh konfigurasi, file yang digunakan adalah wp-config.php
. Di server block nginx, tambahkan baris
location = /wp-config-sample.php { access_log off; log_not_found off; deny all; }
baris tersebut memblokir akes ke file wp-config-sample.php
. Setelah restart nginx, load database langsung menjadi < 20% dan load website menjadi normal kembali.