Not a single answer or comment even mentions a possible overhead of the database tables and doesn't take this into account in the SQL query.
This is the most common mistake when somebody asks: "How big is my database X?". And after getting the wrong! total size, asks: "But then why there's so little space left on the partition/disk where database data is located?".
This is how you get actual total size of the database, replace [DATEBASE_NAME] with your database name:
SELECT `TABLE_SCHEMA` AS "Database", format_bytesFORMAT_BYTES(SUM(`DATA_LENGTH` + `INDEX_LENGTH` + `DATA_FREE`)) AS "Total Size" FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = '[DATEBASE_NAME]';
* when using MariaDB instead of MySQLversion <11.8, then prepend function format_bytesname FORMAT_BYTES with "sys.": sys.format_bytes .
Result:
+----------------+------------+
| Database | Total Size |
+----------------+------------+
| v3 | 3.56 GiB |
+----------------+------------+