Try this code:
SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{your_db}';
For InnoDB tables, the row count is only a rough estimate used in SQL optimization.
For exact counts, you can use COUNT(*). But, for InnoDBtables row count is not exactly matched in SQL optimization.
For more information, you can refer to this DOCS.