Skip to content

Instantly share code, notes, and snippets.

@isyutaro
Last active December 20, 2018 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save isyutaro/6813979 to your computer and use it in GitHub Desktop.
Save isyutaro/6813979 to your computer and use it in GitHub Desktop.
MySQL

Size DB

ALL

mysql> SELECT sum( data_length + index_length ) / (1024 * 1024)  "Size in MB" FROM information_schema.TABLES;

By DB

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / (1024 * 1024) as Size FROM information_schema.TABLES GROUP BY table_schema;

Dump and Restore

Dump all databases and restore one

Dump

mysqldump -u [user] -p --all-databases > [dump_name].sql

Restore one database from dump

mysql -D [mydatabase] -o < [dump_name].sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment