Bash & SQL

Here is a script to count the number of tables in each database:

#!/bin/bash

# MySQL/MariaDB credentials
MYSQL_USER="your_username"
MYSQL_PASSWORD="your_password"

# Connect to MySQL/MariaDB and retrieve list of databases
databases=$(mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)")

# Loop through each database
for db in $databases; do
    echo "Database: $db"

    # Count the number of tables in the current database
    table_count=$(mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -N -e "USE $db; SHOW TABLES;" | wc -l)
    echo "Number of Tables: $table_count"

    echo "---------------------------------------"
done