How to access MySQL Server from command Prompt

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

Log into your server via ssh. Once you are in the shell, 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 inm_dbuser1.

root@xxxxxx [~]# mysql -inm_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)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x