Bash & SQL

Here's a bash script that iterates over each database, then for each database, iterates over its tables and count the number of lines in each table.

#!/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"
    echo "---------------------------------------"

    # Retrieve list of tables for current database
    tables=$(mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -N -e "USE $db; SHOW TABLES;")

    # Loop through each table and count the number of lines
    for table in $tables; do
        line_count=$(mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -N -e "USE $db; SELECT COUNT(*) FROM $table;")
        echo "Table: $table, Line count: $line_count"
    done

    echo
done