How to connect from windows command prompt to MySQL command line - MySQL DBA Tutorial

How to connect from windows command prompt to MySQL command line

To connect to MySQL server on Windows Machine, you can locate mysql application that is location in C:\Program Files\MySQL\MySQL Server xx\bin in case you have done default installation. If you have done manual installation then it depends where your base directory is. I have explained in video with details but most of the cases as you will have only single MySQL on Windows server, you will find mysql application under "C:\Program Files\MySQL\MySQL Server xx\bin".

xx defines the version. If I have used MySQL 8.0 for installation then it will be "C:\Program Files\MySQL\MySQL Server 8.0\bin".

To connect to MySQL Server on windows Machine, open Command line by going to search or going to Run and typing cmd.
On windows command line, go to "C:\Program Files\MySQL\MySQL Server 8.0\bin" by using 

cd C:\Program Files\MySQL\MySQL Server 8.0\bin

To connect to MySQL Server on default port , that is 3306, you will type


C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p
Provide the password and you will be connected to MySQL Server command line.

If you are using different port for MySQL then use below command, I have used xxxx, let's say if you are using port 3307 then change xxxx with 3307.

C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p --port=xxxx

Check the video for detail demo , how I connected with default MySQL server and MySQL running with different port than 3306.