MySQL – How to Connect to MySQL Server on Command Prompt

I have so far authored 5 courses on MySQL at Pluralsight, and one of the most popular question, I keep on getting is how to connect to MySQL with Command Prompt. You may find it funny enough that people who are learning MySQL would know how to connect to command prompt, but trust me, we all start from somewhere and we do not have to be an expert at everything. I respect every single question and I would like to answer this very question over here.

Step 1: Go to the folder where the MySQL exe file is located

For example, in my machine the location of the MySQL execution file is at “C:\Program Files\MySQL\MySQL Server 5.6\bin”. I changed the context of the command prompt to the folder where the MySQL exe file is located.

MySQL - How to Connect to MySQL Server on Command Prompt connect1

Step 2: Enter following commands in the command prompt

mysql -h nameofthehost -u username -p

MySQL - How to Connect to MySQL Server on Command Prompt connect2

In the above command, replace nameofthehost with actual host name and username with actual username. Now click on enter.

MySQL - How to Connect to MySQL Server on Command Prompt connect3

When clicked enter, it will ask for the password. Enter the password and click on enter.

MySQL - How to Connect to MySQL Server on Command Prompt connect4

It will connect you with MySQL Server.

Well – that’s it! You are connected to MySQL Server. Once you connect to MySQL Server, do not forget to continue watching MySQL Basics and Performance Tuning courses.

Reference: Pinal Dave (https://blog.sqlauthority.com)

MySQL
Previous Post
SQL SERVER – Does Use of CTE Change the Order of Join in Inner Join
Next Post
SQL SERVER – SSIS Execution Control Using Precedence Constraints – Notes from the Field #021

Related Posts

2 Comments. Leave new

Leave a Reply