Skip to content

Instantly share code, notes, and snippets.

@h3nr1ke
Last active August 14, 2018 13:50
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 h3nr1ke/6bafa9db52692e82e1ab9c52ee53c136 to your computer and use it in GitHub Desktop.
Save h3nr1ke/6bafa9db52692e82e1ab9c52ee53c136 to your computer and use it in GitHub Desktop.
Access mysql remote server using command line
# if you dont have the tool
# apt-get install mysql-client
mysql -u [USER] -p[PASS] -h [REMOTE_HOST] [DATABASE_NAME]
# after this commmand, the prompt will be
# mysql>
# and will accept SQL commands
# mysql> Select * from yourtable;
# type exit when you are finished
# mysql> exit
# database dump
mysqldump -u [USER] -p[PASS] -h [REMOTE_HOST] [DATABASE_NAME] > database_dump.sql
# dump all databases
mysqldump -u [USER] -p[PASS] -h [REMOTE_HOST] --all-databases > all_databases_dump.sql
#local file to remote server
mysql -u [USER] -p[PASS] -h [REMOTE_HOST] [DATABASE_NAME] < file.sql
#from terminal, display the size of all databases
SELECT table_schema "database", sum(data_length + index_length)/1024/1024 "size in MB" FROM information_schema.TABLES GROUP BY table_schema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment