Nov
6
2014

How to connect Mysql using command line (cmd)

Hi in this post we will see how to connect mysql database using command line(cmd) .Many time it may happen that we don’t have UI( like MySql Yog) to interact with database or we may want to run sql queries in command line instead of standard database editor.

It is very simple we just need to take care of few things that i have discussed below :-

how to connect mysql from command line

  • First of all we need to enter in the bin folder of Mysql .Copy the path up to bin folder and paste it on command line screen .Note that (ctrl+v ) may not work .So you may need to paste in standard way i.e right click and then paste . Append cd which mean change directory with the path up to bin folder and press enter .Now you have entered in bin folder of mysql installed directory .
  • Now you need to type Mysql -u root -p and hit enter key .please note that here root is the user name of  mysql.The command is mysql hi-fen u username hi-fen p.If you type anything else it may end up with

    ERROR 1049 (42000): Unknown database error

  • In next step you need to type password that was being asked from you while installing mysql and hit enter key.

  • Now to connect to any particular database just type connect command and then database name and hit enter key.Now you are connected to that database .
  • Now you can perform any operation on your database .  

That is all in this post .Take care have fun .I will see you soon with next post .

 

About the Author: devender kumar

java/j2EE developer

Comments are closed.