Feb.07
Mysql database connection and back up from ssh client
Log in to your Hosting account using SSH.
step 1: At the command line, type the following command, replacing USERNAME with your username:
mysql -u USERNAME -p
At the Enter Password prompt, type your password. When you type the correct password, the mysql> prompt appears.
To display a list of databases, type the following command at the mysql> prompt:
To access a specific database, type the following command at the mysql> prompt, replacing DBNAME with the database that you want to access:
mysql> Use holycros_drupal;
After you access a database, you can run SQL queries, list tables, and so on. Additionally:
- To view a list of MySQL commands, type help at the mysql> prompt.
- To exit the mysql program, type \q at the mysql> prompt.
Lets look at some of the other functions you can execute via SSH. If you want, for example, to move and copy a file to a different folder you need to type the following:
mv index.html /path/to/directory/index.html ( this command will move it)
cp index.html /path/to/directory/index.html (this command will copy it)
Copying a whole folder is done using the -r option of the cp command. This will copy the whole folder recursively for example:
cp -r /path/to/folder /destination/path
The mv command can also be used to rename a file. For example:
mv index.html newindex.html
Note that unlike windows, Linux files are key sensitive, so if you are going to move or edit a file you must type the exact name.