Import a database via command line

mysql -uroot -proot [existing-database] < ~/dev/[new-database].sql

Specifically ask for MAMP PRO mysql

MAMP/MAMP Pro is an application that runs a MySQL, Apache and PHP stack on Mac.


/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

Get size of all databases

SELECT table_schema AS "Database name", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;

Get size of all tables in a database

SELECT
  table_schema as `Database`,
  table_name AS `Table`,
  round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;