Access MySQL Server From The Shell Prompt (Command Line)

MySQL software includes mysql client. It is a text-based client for mysqld, a SQL-based relational database server. It works interactive and non-interactive mode

  • Log into your server via ssh.
  • Once in your shell, you will at the command line prompt.
  • To log into the MySQL monitor,
    Use the following syntax:

root@xxxxxx:/#mysql -u <db-username> -p

The <db-username> tag will need to be replaced with the actual database username with which you want to
sign into the monitor.

Note: If you do not know which user you want to use, you can find a list of users
for your databases via your cPanel.

Once you have your database username, enter command line code similar to below and hit Enter.
In our case, we are using a database usernamed inmoti5_dbuser1.

root@vps9999 [~]# mysql -u inmoti5_dbuser1 -p
Due to the -p switch with nothing following, you will be required to enter your password as below.
Simply enter the password and click Enter.
Enter password:
After entering the correct password you will be met with the following greeting and MySQL prompt:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.30-0ubuntu0.15.10.1 (Ubuntu)
mysql>

http://www.inmotionhosting.com/support/website/databases/mysql-command-line

http://www.cyberciti.biz/faq/how-do-i-access-mysql-server-from-the-shell-prompt-command-line/

https://www.digitalocean.com/community/tutorials/a-basic-mysql-tutorial