Secure-Shell (SSH) Reference Sheet – Database

This is the continuation of my Secure-Shell Reference Sheet – Basic.

Note: Anything surrounded by *asterisks* is where your input is required.

Accessing a Database
mysql -u *username* -p *password* -h *hostname* *database*

This will log in directly

mysql -u *username* -h *hostname* *database*

This will prompt you for the database user’s password

Export a database using gzip
mysqldump -u *username* -p *password* -h *hostname* *database* | gzip > *database*.sql.gz
Import a database using gzip
gzip -d < *database*.sql.gz | mysql -u *username* -p *password* -h *hostname* *database*

If you have any other commands you wish me to include, leave a comment below!

Leave a Reply

Your email address will not be published. Required fields are marked *