Monday, March 20, 2017

Execute query in mysql using command prompt

Tags



There are time where we as a programmer been forced to use cmd instead of gui software. People thought that it will become much harder if everything done by command prompt. Well, that not 100% true. By learning to use software by command prompt will make you understand better about the software architecture and how powerful it is. This tutorial will teach you all on how to execute query in mysql using only command prompt. Enjoy!

First, navigate to the mysql.exe in cmd.

Example, 


There nothing special syntax that you need to change, it all the same.

Below is some of the example query for your reference.

Create user in mysql
mysql.exe -u root -e "CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'";

Grant Privileges
mysql.exe -u root -e "GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'";

Flush Privileges
mysql.exe -u root -e "FLUSH PRIVILEGES";

Create database
mysql.exe -u root -e "CREATE DATABASE titan";

Delete database
mysql.exe -u root -e "DROP DATABASE database_name";

Select database
mysql.exe -u root -e "USE database_name";


If you are facing any problem on this, don't hesitate to message at Obstrum facebook page.

Hope this tutorial will help those in need.

If you want to get in touch with more tutorial, add me on google+ or like and follow our facebook page for more! Obstrum Facebook Page


EmoticonEmoticon