KONEKSI MYSQL Dari Program Apapun

Embed Size (px)

Citation preview

  • 7/26/2019 KONEKSI MYSQL Dari Program Apapun

    1/4

    KONEKSI MYSQL dari Program apapun (Tested Delpgi 7 n PHP !

    sumber : http://ubuntu-commands.blogspot.com/2008/11/how-do-i-enable-remote-access-to-mysql.html

    Intinya : Karena y!ql !er"er menola# semua #one#si yang berasal dari dirinya sendiri yangdide$inisi#an di#on$igurasi mysql sendiri /etc/mysql/my.cn$ %&buntu 8.0'(.

    )roses Ker*a :1. +u#a ,ile /etc/mysql/my.cn$2. engganti -bind-address 12.0.0.1 dengan bind-address ip-ser"er

    . estart !er"er ysql : /etc/init.d/mysql restart

    '. 3ari sisi ysql sendiri4 buat database database : 5676 377+7!6 database

    9. +uat user untu# menga#ses database tersebut %disaran#an( : 7; 7 = database?@A@ I36;I,I63 +B @password-user-database@C

    A untu# mengiDin#an database dia#ses oleh user-database dari manapun

    %disaran#an untu# menspesi$i#asi#an I) yang diguna#an untu# menga#ses bila

    memung#in#an(

    &ntu# #one#si di 3elphi : buat =3+5 untu# #one#si lebih mudah&ntu# )E) : langsung

    !ampai disini sudah bisa y!F< dihubungi dari luar4 untu# tutorial yang ada dibawah setelahproses ini4 merupa#an setting pengaturan penga#sesan dari luar%alasan #eamanan(

    Eow 3o I 6nable emote 7ccess o y!F< 3atabase !er"erG

    Eow 3o I 6nable emote 7ccess o y!F< 3atabase !er"erG

    +y de$ault4 y!F< database ser"er remote access disabled $or security reasons. Eowe"er4 some

    time you need to pro"ide the remote access to database ser"er $rom home or $rom web ser"er.

    y!F< emote 7ccess

    Bou need type the $ollowing commands which will allow remote connections:

    !tep H 1:

  • 7/26/2019 KONEKSI MYSQL Dari Program Apapun

    2/4

    !tep H 2: 6nable networ#ing

    =nce connected you need edit the mysql con$iguration $ile my.c$g using tet editor such as "i.

    > I$ you are using 3ebian I$ you are using ed Eat

  • 7/26/2019 KONEKSI MYSQL Dari Program Apapun

    3/4

    > bind-address : I) address to bind to.

    > s#ip-networ#ing : 3onMt listen $or 5)/I) connections at all. 7ll interaction with mysqld must

    be made "ia &ni soc#ets. his option is highly recommended $or systems where only local

    requests are allowed. !ince you need to allow remote connection this line should remo"ed $rom

    $ile or put it in comment state.

    !tepH ' !a"e and 5lose the $ile

    estart your mysql ser"ice to ta#e change in e$$ect:H /etc/init.d/mysql restart

    !tep H 9 rant access to remote I) address

    H mysql -u root -p mysqlrant access to new database

    I$ you want to add new database called $oo $or user bar and remote I) 202.9'.10.20 then you

    need to type $ollowing commands at mysqlN prompt:mysqlN 5676 377+7!6 $ooC

    mysqlN 7; 7 = [email protected]'.10.20@ I36;I,I63 +B @)7!!L=3@C

    Eow 3o I rant access to eisting databaseG

  • 7/26/2019 KONEKSI MYSQL Dari Program Apapun

    4/4

    = only allow remote connection $rom your web ser"er located at 10.9.1.:

    /sbin/iptables -7 I;)& -i eth0 -s 10.9.1. -p tcp --destination-port 0 -* 7556)

    = only allow remote connection $rom your lan subnet 1O2.18.1.0/2':

    /sbin/iptables -7 I;)& -i eth0 -s 1O2.18.1.0/2' -p tcp --destination-port 0 -* 7556)

    7 sample ,ree+!3 / =pen+!3 p$ rule % /etc/p$.con$(

    pass in on PetQi$ proto tcp $rom any to any port 0

    = allow only access $rom your web ser"er located at 10.9.1.:

    pass in on PetQi$ proto tcp $rom 10.9.1. to any port 0 $lags !/!7 synproy state

    !tep H : est it

    ,rom remote system or your des#top type the command:

    P mysql -u webadmin Rh 9.99.99.2 Rp

    Lhere4

    > -u webadmin: webadmin is y!F< username

    > -h I) or hostname: 9.99.99.2 is y!F< ser"er I) address or hostname %,F3;(

    > -p : )rompt $or password

    Bou can also use telnet to connect to port 0 $or testing purpose:P telnet 9.99.99.2 0