Hello, today i will share tutorial about how to accessing mysql through command prompt. There's many tutorial like this in others blog, but in my blog you can feel different because you can get a tutorial in english version. Before we start the tutorial i would say sorry if you can't understand with my sentences because i just wanna improve my english with writing this tutorial. Let's try :)
To open the cmd window you must click start - run - cmd - and then push the enter button. After that, we go to the directory where is mysql installed. In my computer that i used to write this tutorial, mysql is in the directory d:\xampp\mysql\bin. To run mysql.exe in the bin folder we must type : cmd d:\xampp\mysql\bin. Now the position is in the directory d : \xampp\mysql\bin, and type mysql -u root -p
Information :
mysql -u root -p
-u : username for login to database, in this case i used root
-p: followed by -p for password that i used (push the enter button if we didn't use a password)
If it successful then the visible message Welcome to the MySQLmonitor like this
Now we already lay in the MySQL database, especially with root permissions so all in our hands now. And then what we do here now? Here i describe some of the parts.
- Command to create a new database
mysql > create database [name of the database];
ex : mysql > create database latihan;
- Command to use database
mysql > show databases;
- Command to use database
mysql > use [database that you choose];
ex : mysql > use latihan;
If it appears database changed, then the current position in the database latihan and now we can access all the tables in database latihan.
- Command to create a new table
mysql > create table [name of the table] ([coloumn name], [coloumn type], [...]) ;
ex : mysql > create table data (ID int(100), nama varchar(255), alamat varchar(255)) ;
- Command to show table in database
mysql > show tables;
- Command to insert data
mysql > INSERT INTO [table name] ([coloumn name]) VALUE ([coloumn values]);
ex : mysql > INSERT INTO data (ID, nama, alamat) VALUE (1,"Andro","Jl.Margonda");
- Command to perform query on an existing table
mysql > Select * from data;
- Command to delete table
mysql > drop tables [table name];
ex : mysql > drop tables data;
- Command to delete database
mysql > drop database [database name];
ex : mysql > drop database ujian;
- Command to exit from database mysql
mysql > exit
There is many sql syntax that we can use, essentially all of the syntax of the query can be executed via comand prompt. Now, you can try it yourself :)
0 komentar:
Posting Komentar