Sitemap

Monitoring Mysql with uptime kuma

2 min readDec 20, 2025

--

Install MySQL

To install MySQL, run the following command from a terminal prompt:

sudo apt install mysql-server

Once the installation is complete, the MySQL server should be started automatically. You can quickly check its current status via systemd:

sudo service mysql status

login to mysql server

mysql -u root -p

create database

CREATE DATABASE dummy;

use dummy database

use dummy;

create table on database dummy with 2 coloumb

CREATE TABLE datadummy (
firstName varchar(255),
lastName varchar(255)
);

make mysql user and grant permission

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'@'localhost';
GRANT ALL ON *.* TO 'myuser'@'%';
FLUSH PRIVILEGES;

exit mysql

EXIT;

Create data dummy to datadummy table on dummy database, we can use di bash script to add dummy data

#!/bin/bash
# Set PostgreSQL database connection parameters
DB_HOST="localhost"
DB_PORT="3306"
DB_NAME="dummy"
DB_USER="myuser"
DB_PASSWORD="mypass"
TABLE_NAME="datadummy"
# Prompt user for maximum index count
read -p "Enter the maximum index count for inserting rows: " max_count
# Check if max_count is a valid number
if ! [[ "$max_count" =~ ^[0-9]+$ ]]; then
echo "Error: Please enter a valid number."
exit 1
fi
# Function to generate a random string of given length
generate_random_string() {
local length=5
# Generate a random string using /dev/urandom, then trim to the desired length
tr -dc A-Za-z0-9 </dev/urandom | head -c $length
}
# Export password for non-interactive use (be cautious with this)
export PGPASSWORD=$DB_PASSWORD
# Loop and insert rows up to the max_count
for (( i=1; i<=max_count; i++ ))
do
# Generate random data for each insert
random_string=$(generate_random_string ) # Random string of 10 characters
random_integer=$((RANDOM % 1000)) # Random integer between 0 and 999
# Execute the query
QUERY="INSERT INTO $TABLE_NAME(userdata,usertest) VALUES ('$random_string','$random_string');"
mysql -h $DB_HOST -p$DB_PASSWORD -u $DB_USER -D $DB_NAME -e "$QUERY"
if [ $? -eq 0 ]; then
echo "Inserted row $i successfully with random data."
else
echo "Failed to insert row $i."
break
fi
done
# Unset the password environment variable for security
unset PGPASSWORD
echo "Insertion complete up to index count $max_count."

go to uptime kuma host

Get Andre’s stories in your inbox

Join Medium for free to get updates from this writer.

uptime kuma run on docker

docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1

add new monitor

--

--