Thursday, August 26, 2010

how to install mysql and used it

Now we will study about Mysql, MySQL is a database management system (DBMS) that runs in a server and providing multi-user access to a number of databases.

you can install mysql on ubuntu use terminal and you must log in as root

ira@dwirahmah:~$ sudo apt-get install mysql-server

put your password root, and it will be install automatic.

after instalation process has finished, you can use mysql.
fisrt you log in mysql use terminal :
  1. Log in to mysql :
    ira@dwirahmah:~$ mysql -u root -p
    (Put your password root on mysql)

  2. Create a database :
    mysql> create database test;

  3. To Show databases in your server :
    mysql> show databases;

  4. Create a Table in a database "test" :
    mysql> use database test; ---> to enter into database
    mysql> create table belajar (nim char(8) not null, NAMA char(25) not null,
    ALAMAT char(30) not null);
  5. Show all table from database "test" :
    mysql> show tables;
  6. To Insert record to table "belajar" in database :
    mysql> insert into belajar values ("1234","Ira Dwi","Jakarta");
  7. To Update of a record in table "belajar":
    mysql> update belajar set Nama="Ira Dwi Rahmah" where nim="1234";
  8. To show all record from table "belajar":
    mysql> select * from belajar;

  9. To delete record from table "belajar";
    mysql> delete from belajar;
  10. Detele Table "belajar" :
    mysql> drop table belajar;
  11. Delete database "test" :
    mysql> drop database test;

0 comments:

Post a Comment