Command line instructions for ssh and mysql

A quick and very basic list of commands to get you started with command line.

If you need to know how to log in to ssh with command line and manage a database you can follow the instructions below. You will find how to import a database with command line, how to export it and how to drop it. There are also some other quick tips if you are working with Wordpress.

I use this step-by-step to manage Wordpress sites and their relative database.

Log in to ssh

ssh your_username@your_domain.com

Drop old database
Delete the existing DB

mysqladmin -u your_username -p drop database_name

Create database

mysqladmin -u your_username -p create database_name

Import database

mysql –h my_sql_host –u my_slq_username –p my_sql_dbname < dbname.sql

Update .htaccess file and make it writable

Go to root folder then type: -be careful when changing permissions

touch .htaccess
chmod 666 .htaccess

Export a database

mysqldump -h my_sql_host -u my_slq_username -p my_sql_dbname > dbname.sql

Copy a database to Desktop
log out of ssh

scp username@server.com:filepath/filenamw.txt ~/Desktop