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.

Command line window with MySQL executable file path.

Step 2: Enter following commands in the command prompt

mysql -h nameofthehost -u username -p

Command prompt with MySQL connection.

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

Root user in mysql command prompt.

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

MySQL login window.

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.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.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

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.