Skip to content

Instantly share code, notes, and snippets.

@andresaquino
Forked from isyutaro/mysql.md
Created December 20, 2018 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andresaquino/1129f3be5d4dd9a56a49e0974cf19cc9 to your computer and use it in GitHub Desktop.
Save andresaquino/1129f3be5d4dd9a56a49e0974cf19cc9 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