Last active
August 14, 2018 13:50
-
-
Save h3nr1ke/6bafa9db52692e82e1ab9c52ee53c136 to your computer and use it in GitHub Desktop.
Access mysql remote server using command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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