Please Wait, Loading...

Friday 26 November 2010

Instalasi dB MySQL untuk Joomla di Centos

Database MySQL
  1. Instalalasi MySQL di Centos 
    [root@uii /]# export http_proxy="http://192.168.xxx.xxxx:8080"
    [root@uii /]# export ftp_proxy="http://192.168.xxx.xxxx:8080"
    [root@uii /]# yum install mysql-server mysql php-mysql

  1. Konfigurasi MySQL
    1. Menjalankan proses MySQL
 [root@uii /]# /etc/init.d/mysqld start
  [root@uii /]# chkconfig –-level 235 mysqld on

    1. Inisialisasi password MySQL
[root@uii /]# mysql –u root   
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    1. Konfigurasi Password root
[root@uii /]#    /usr/bin/mysqladmin -u root password '*************'
[root@uii /]# /etc/init.d/mysqld restart
Stopping MySQL:                                     [  OK  ]
Starting MySQL:                                     [  OK  ]
[root@uii /]# chkconfig --level 235 mysqld on
[root@uii /]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

  1. Operasional BasisData MySQL
    1. Fungsi Help
mysql> \h
For information about MySQL products and services, visit:
  http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
  http://dev.mysql.com/
To buy MySQL Network Support, training, or other products, visit:
  https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new deli  miter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with   multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
For server side help, type 'help contents'

    1. Menampilkan database
mysql> show databases;
+----------------------------+
| Database               |
+-----------------------------+
| information_schema |
| mysql                    |
| test                      |
+----------------------------+
3 rows in set (0.00 sec)
    1. Menampilkan Tabel
mysql> use mysql, mysql> show tables;
+----------------------------------------+
| Tables_in_mysql                |
+----------------------------------------+
| columns_priv                     |
| db                                   |
| func                                |
| help_category                   |
| help_keyword                    |
| help_relation                     |
| help_topic                        |
| host                                |
| proc                                |
| procs_priv                        |
| tables_priv                       |
| time_zone                        |
| time_zone_leap_second      |
| time_zone_name                |
| time_zone_transition          |
| time_zone_transition_type  |
| user                               |
+---------------------------+
17 rows in set (0.00 sec)
    1. Membuat User baru di tabel user
mysql> INSERT INTO user (host,user,password) values ('192.168.xxx.xxx','devweb','*******');

    1. Melihat isi field user
mysql> describe user;
+-----------------------+---------------+------+-----+---------+---------------+
| Field                 | Type          | Null | Key | Default | Extra |
+-----------------------+---------------+------+-----+---------+--------------+
| Host                  | char(60)      | NO   | PRI |         |       |
| User                  | char(16)      | NO   | PRI |         |       |
| Password           | char(41)      | NO   |       |         |       |
+-----------------------+----------------+------+-----+---------+------------+
37 rows in set (0.01 sec)

    1. Menampilkan field host, user dan password
mysql> select host,user,password  from user;
+-----------------+--------------+----------------------------------------------------------+
| host                 | user               | password                                 |
+-----------------+--------------+-----------------------------------------------------------+
| localhost           | root             | 394944a314f0aa7c                      |
| serverdemo        | root             |  90987768tyyhsjdh$#9&*             |
| 192.168.xxx.xxx  |devweb         | uyritfh43535                               |
+-----------+------+-------------------------------------------------------------------------+
6 rows in set (0.00 sec)
    1. Membuat database joomla_db
mysql> create database joomla_db;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+------------------------------+
| Database                |
+------------------------------+
| information_schema |
| joomla_db              |
| mysql                    |
| test                      |
+-----------------------------+
4 rows in set (0.00 sec)

    1. Grant joomla_db agar dapat diakses oleh user lain dari perijinan root
Mengapa perlu di grant, Karena database ini dibuat oleh root sehingga tidak akan bisa dapat diakses oleh user lain, kecuali jika ada perijinan oleh root. Dengan demikian, utnuk menggunakan database ini dari account (root) harus mengatur perijinan dengan melakukan “Grant”

mysql> grant all on joomla_db.* to root@localhost identified by "*******" \g
Query OK, 0 rows affected (0.00 sec)

    1. Membuat tabel di database test
mysql> create table anaconda (Nama varchar(20), Alamat varchar(100), Telp int(10));

    1. Menampilkan field dari tabel anaconda
mysql> describe anaconda;
+--------+----------------------+----------+--------+---------+-------+
| Field    | Type             | Null    | Key | Default | Extra |
+--------+---------------------+-----------+-------+---------+-------+
| Nama   | varchar(20)    | YES   |       | NULL     |       |
| Alamat | varchar(100)    | YES  |      | NULL      |       |
| Telp     | int(10)           | YES   |      | NULL       |       |
+--------+----------------------+----------+--------+---------+-------+
3 rows in set (0.00 sec)

    1. Menghapus tabel anaconda
mysql> drop table anaconda;
Query OK, 0 rows affected (0.01 sec)

    1. Mengapus database test_db
mysql> drop database test_db;
Query OK, 0 rows affected (0.00 sec)

    1. Menghapus field Telp
mysql> alter table id drop Telp;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

    1. Menambahkan field Status
mysql> alter table id add Status varchar(100);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

Semoga bermanfaat