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.

Step 2: Enter following commands in the command prompt

mysql -h nameofthehost -u username -p

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

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

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 (http://blog.sqlauthority.com)

About these ads

SQL SERVER – 2005 – Start Stop Restart SQL Server From Command Prompt

Very frequently I use following command prompt script to start and stop default instance of SQL Server. Our network admin loves this commands as this is very easy.

Click Start >> Run >> type cmd to start command prompt.

Start default instance of SQL Server
net start mssqlserver

Stop default instance of SQL Server
net stop mssqlserver

Start and Stop default instance of SQL Server.
You can create batch file to execute both the commands together.

Reference : Pinal Dave (http://blog.SQLAuthority.com)