Site Search :
Standard Enterprise XML Methodology Pattern Setting Tunning Other
Article Contributors
GuestBook
Javapattern Maven
XSourceGen Dev
JetSpeed Test
JLook Image
jLook Family Site


MySQL JDBC Connection
 
ÇÁ·Î±×·¡¹Ö¿¡ À־ µ¥ÀÌÅͺ£À̽º´Â ¾ø¾î¼­´Â ¾ÈµÉ µµ±¸ÀÌ´Ù. ÀÚ¹Ù´Â À¯¿¬ÇÑ JDBC¸¦ Á¦°øÇÑ´Ù. ÀÌ JDBC¸¦ ÅëÇؼ­ MySQLÀ» Á¢¼ÓÇÏ¿© µ¥ÀÌÅ͸¦ °¡Á®¿Àµµ·Ï ÇÏÀÚ ( 2003/02/28 ) 553
Written by ienvyou - ÃÖÁö¿õ
1 of 3
 
---------------------------------------
1. MySqlÀ̶õ ¹¹ÁÒ?
---------------------------------------
MySqlÀ̶õ DBMSÀÇ ÀÏÁ¾ÀÔ´Ï´Ù.
À߾˷ÁÁø DBMS·Î´Â ORACLE,DB2,Sybase,Infomix,.... Ingress,PostgreSQL...MiniSQL
±¹»êÀ¸·Î´Â UniSQLÀ̶õ°ÍÀÌ ÀÖÁÒ.
±×Áß °ø°³¿ëÀ¸·Î ¹ßÇ¥µÇ¾î ÀÖ´Â°Ç miniSQL,PostgreSQL,MySql..µîÀÌ ÀÖÁÒ.
miniSQLÀº °³ÀÎ(?)ÀÌ ¸¸µé°íÀÖ°í, ÀÛ°í ºü¸£Áö¸¸, ÀÎÁõ½Ã½ºÅÛÀÌ ¾øÁÒ.
PostgreSQLÀº »ó¿ëDBMS¸¸Å­ÀÇ ¼º´É°ú ±â´ÉÀ» ±âÁö°í ÀÖ°í °ø°³ÀûÀÎ 
°³¹ßÀÌ ÀÌ·ïÁö°íÀÖÁö¸¸ µ¢Ä¡°¡ Å©°í,UNIX¹öÀü¸¸ ÀÖÁÒ. NT·Î portingÇÏ´Â ¹æ¹ýÀº 
³ª¿Í Àִµ¥ ±î´Ù·Ó°í...
MySQLÀº ÀÛ°í ºü¸£°í(ORACLEÀÇ 2~5¹èÁ¤µµ) ¸¹Àº Application¿¡¼­ Áö¿øÇÏ°í ÀÖÁÒ.
Windows¿ëµµ UNIX¹öÀü¸¸Å­ ºü¸¥ upgrade°¡ µÇ°í ÀÖÁÒ.


---------------------------------------
2. MySql ¾îµð¼­ ¾î¶² ¹öÀüÀ» ´Ù¿î ¹Þ¾Æ¾ß Çϳª¿ä?
---------------------------------------
MySql ȨÆäÀÌÁö : http://www.mysql.com/
MySql°ü·Ã ÇѱۻçÀÌÆ® : http://www.taejun.pe.kr/

¾ó¸¶Àü±îÁö¸¸Çصµ Win¿ë MySqlÀº shareware¿´°í ¹öÀüµµ UNIX¹öÀüº¸´Ù ´Ù¼Ò µÚ¶³¾îÁ³¾úÁö¸¸
ÀÌÁ¦´Â GPLÀ» µû¸£°í ÀÖ°í , ¹öÀüµµ UNIX¿Í °°ÀÌ °¡°í ÀÖ´Ù. ÇѸ¶µð·Î °øÂ¥·Î ¾µ ¼ö ÀÖÀ¾´Ï´Ù.

http://www.mysql.com/downloads/  ¿¡¼­ ÃֽŹöÀüÀ¸·ÎÀÇ ¸µÅ©¸¦ µû¶ó°¡°í  ±× ÆäÀÌÁö¿¡¼­ 
Standard binary (tarball) distributions ¹Ù·Î ¾Æ·¡
windows¿ë(http://www.mysql.com/Downloads/MySQL-3.23/mysql-3.23.33-win.zip)À» ¹Þ°í

winzipÀ̳ª ¾ËÁýÀ¸·ÎÇ®¾î setup.exe¸¦ ½ÇÇà½ÃÅ´.

¼³Ä¡½Ã ÁÖÀÇÁ¡ : µÇµµ·Ï ¼³Ä¡ µð·ºÅ丮´Â c:\mysql ·Î ÇÒ°Í. 
¸¸¾à ´Ù¸¥ µå¶óÀ̹öÀÏ°æ¿ì c:\my.cnfÆÄÀÏÀ» ¸¸µé°í..... µîµîÀÇ ±ÍÂúÀº ÀÏÀÌ »ý±è.
ÀÚ¼¼ÇÑ »çÇ×Àº ¼³Ä¡½Ã È­¸é¿¡ ¶ä.

---------------------------------------
3. MySql¿ë JDBC driver´Â ¾îµð¿¡ ÀÖ³ª¿ä?
---------------------------------------
JDBC´Â http://www.worldserver.com/mm.mysql/  ¿¡ °¡¼­
2.0.4 ¼Ò½º¹öÀü(http://www.worldserver.com/mm.mysql/dist/mm.mysql-2.0.4-src.jar)À»
¹ÞÀºÈÄ Ç®¸é mysql.jar°¡ Àִµ¥ ±×°É¾²¸éµÊ.
¼Ò½º¹öÀü¸»°í binary ¹öÀü( ¾à 108K )À» ½áµµµÊ. ±×°Ç ¼Ò½º¹öÀüÀÇ mysql.jar¿Í µ¿ÀÏÇÑ À̸§ÀÓ.
mysql.jar¸¦ c:\jdk1.2.2\jre\lib\ext ¿¡ º¹»çÇÏ¸é µË´Ï´Ù.

ÇѱÛÀ» ÀÔÃâ·Â ÇÒ¶§¿¡´Â convertingÇÏÁö ¾Ê½À´Ï´Ù. 
ÇöÀç JDBC2.0±îÁö Áö¿øµÊ.
³»¿ëÀ» ºÃ´õ´Ï ±âƯÇÏ°Ôµµ JDK 1.1.*¿¡¼­´Â JDBC 1.0¸¸, Java2¿¡¼­´Â JDBC 2.0±îÁö 
Áö¿øµÇµµ·Ï ¾ÆÁÖ ±³¹¦(?)ÇÏ°Ô ¸¸µé¾î ³ùÀ½.

---------------------------------------
4. MySqlÀº ¾î¶»°Ô ½ÇÇà½ÃÅ°³ª¿ä?
---------------------------------------
½ÃÀÛÀº mysql¼³Ä¡ µð·ºÅ丮 ¾Æ·¡bin¿¡(C:\mysql\bin) °¡¼­  mysqld.exe ¸¦ ½ÇÇà.
dosâÀÌ Àá½Ã º¸¿´´Ù°¡ ¾ø¾îÁü.
( ³î¶óÁö¸¶¼¼¿ä. CTRL-ALT-DELÀ»´­·¯º¸¸é 
mysqld-opt.exe(win95/98)³ª mysqld-nt.exe(winnt/2000)°¡ ½ÇÇàÁß )

È®Àιý:
prompt> cd c:\mysql\bin
prompt> mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.21-beta

Type 'help' for help.

mysql>

c:\mysql\bin\mysql.exe´Â mysql¿ë client program
ÀÌ·¯ÇÑ ¸Þ¼¼Áö°¡ ¶ß¸é Á¤»óÀûÀ¸·Î MySql¼­¹ö°¡ µ¿ÀÛÁßÀÓ.
±×¸®°í °£´ÜÇÑ ¸í·É¾î ¸î°³¸¦ ÀÔ·ÂÇغ¸ÁÒ.

mysql> show databases;      --> ±âº»ÀûÀ¸·Î ¸¸µé¾îÁ®ÀÖ´Â database À̸§ Ãâ·Â
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.00 sec)

mysql> select user();       --> ·Î±äÇÑ »ç¿ëÀÚ Á¤º¸ Ãâ·Â
+----------------+
| user()         |
+----------------+
| ODBC@localhost |
+----------------+
1 row in set (0.08 sec)

mysql>


À§¿Í°°ÀÌ ³ª¿À¸é Á¤»óÀûÀÎ ¼³Ä¡ÀÓ.
³¡³»·Á¸é exitÀ̶óÇÏ¸é µÊ.

mysql> exit;

---------------------------------------
5. Winnt/Win2000¿¡¼­ ¼­ºñ½º·Î µ¿ÀÛ ½Ãų ¼ö ÀÖ³ª¿ä?
---------------------------------------

winnt/win2000¿¡¼­´Â mysqlÀ» ¼­ºñ½º·Î µî·Ï°¡´É.
¹æ¹ý 1 (command line ):  mysql¼³Ä¡ µð·ºÅ丮 ¾Æ·¡bin¿¡ °¡¸é mysqld.exeÀÖÀ½.

prompt> mysqld     -install  ( service·Î µî·Ï )
prompt> net start mysql   ( mysql ¼­ºñ½º ½ÃÀÛ )


prompt> net stop mysql ( mysql ¼­ºñ½º ÁßÁö )
prompt> mysqld     -remove ( service¿¡¼­ µî·Ï ÇØÁ¦ )

¹æ¹ý 2 (GUI) : c:\mysql\bin\win,ysqladmin.exe¸¦ ½ÇÇà½ÃÅ´.
±×·¯¸é userid¿Í ¾ÏÈ£¸¦ ¹¯´Â È­¸éÀÌ ¶ã¶§ userid´Â root, ¾ÏÈ£´Â sunedu21À» ÀÔ·Â.
ÀÔ·ÂÇÑ root´Â ±âº»ÀûÀ¸·Î Á¦°øµÇ´Â °ü¸®ÀÚ¿ë idÀÌ°í ¾ÏÈ£´Â ¾øÀ½. sunedu21À» ÀÔ·ÂÇϸé 
±×°É·Î ÀÚµ¿ ¼³Á¤µÊ.

---------------------------------------
6. mysql.exeÀÇ °£´ÜÇÑ »ç¿ë¹ýÀ»...
---------------------------------------

mysql.exe¸¦ ÀÌ¿ëÇؼ­ ´Ù¸¥ ½Ã½ºÅÛÀÇ database·Î Á¢¼Ó°¡´ÉÇÏ°í ´Ù¸¥ »ç¿ëÀڷεµ Á¢¼ÓÀÌ 
°¡´ÉÇÕ´Ï´Ù.

mysql.exe¿É¼Çµé

prompt> mysql [-h hostname] [-u userID] [-p¾ÏÈ£] [database]

¿¹:
prompt> mysql -h 203.239.XXX.XXX -u root -p sl300

-h 203.239.XXX.XXX  : 203.239.XXX.XXXÀ¸·Î Á¢¼Ó, »ý·«ÇÏ¸é ±âº»°ª 127.0.0.1 ÀÌ »ç¿ëµÊ.
-u root          : root»ç¿ëÀÚ·Î Á¢¼Ó -u¿É¼ÇÀ» ¾ÈÁÖ¸é anonymous·Î Á¢¼Ó
-p               : ¾ÏÈ£¸¦ ÀÔ·ÂÇÑÈÄ Á¢¼Ó. ¾ÏÈ£¸¦ ¹¯´Â ÇÁ·ÒÇÁÆ®°¡ ¶ä.
                   ¾ÏÈ£°¡ ÀÖ´Â »ç¿ëÀÚ·Î Á¢¼Ó½Ã¿¡´Â ¹Ýµå½Ã »ç¿ë.
                   ¸¸¾à ¾ÏÈ£¸¦ °°ÀÌ ÀÔ·ÂÇÏ·Á¸é ¾ÏÈ£¸¦ -p¿É¼Ç°ú ºÙ¿© ÀÔ·Â.(-ptiger)
database         : »ç¿ëÇÒ databaseÀ̸§. ¸¸¾à »ý·«Çϸé Á¢¼ÓÈÄ use¸í·ÉÀ¸·Î 
                   database¸¦ ÁöÁ¤ÇؾߵÊ. ±âº»Á¦°ø database nameÀº mysql,test 2°³.¤¤

---------------------------------------
7. MySql°ü·Ã GUI toolÀº ¾ø³ª¿ä?
---------------------------------------
MySql¿ë GUI toolÀº ´ëºÎºÐÀÌ UNIX/LINUX¿ëÀÔ´Ï´Ù.
´ÙÇàÈ÷ 3.23.21¹öÀüºÎÅÍ´Â winmysqladmin.exe ¶ó´Â GUI toolÀÌ Æ÷ÇԵǾî ÀÖÀ¾´Ï´Ù.
( C:\mysql\bin\winmysqladmin.exe )
ÀÌ ÅøÀº MySql¼­¹ö¸¦ start,stop½Ãų ¼ö ÀÖ°í, NT/2000¿¡¼­´Â service¿¡ µî·Ï,ÇØÁ¦µµ °¡´ÉÇÕ´Ï´Ù.
±×¸®°í ÇöÀç Á¢¼ÓÇÏ°íÀÖ´Â processÀÇ °¹¼ö¿Í MySql°ü·Ã ȯ°æº¯¼ö Á¤º¸¿Í ¼³Á¤Á¤º¸±îÁö 
ÆľÇÀÌ °¡´ÉÇÕ´Ï´Ù.

ÀÌ ÅøÀº win95/98/nt/2000¿¡¼­ ¸ðµÎ µ¿ÀÛÇÕ´Ï´Ù.
À̸í·É¾î¸¦ óÀ½ ½ÇÇàÇϸé Á¢¼Ó½Ã »ç¿ëÇÒ »ç¿ëÀÚid¿Í ¾ÏÈ£¸¦ ³ÖÀ¸¶óÇϴµ¥ ÁÖ·Î root¸¦ ÀÔ·ÂÇÏ°í
¾ÏÈ£´Â ¾Æ¹«°Å³ª ÀÔ·ÂÇϸéµË´Ï´Ù.
´Ü À̶§ ÀÔ·ÂÇÑ ¾ÏÈ£´Â ÀÚµ¿À¸·Î rootÀÇ ¾ÏÈ£·Î ÀνÄÀÌ µË´Ï´Ù. ¹Ýµå½Ã ±â¾ïÇؾ߰ÚÁÒ?

±×·¯¸é ½Ã½ºÅÛÆ®·¹ÀÌ¿¡ ½ÅÈ£µî ¾ÆÀÌÄÜÀÌ »ý±é´Ï´Ù. ÀÌ°É ´©¸£¸é showme ¿Í 
winnt,win9X¸Þ´º°¡ º¸ÀÌÁÒ. winnt,win9X ¸Þ´º¸¦ ¼±ÅÃÇϸé server start,stop toolÀÇ shutdownÀÌ º¸ÀÔ´Ï´Ù.

ÇöÀç mysql server°¡ ½ÇÇàÁßÀ̸é ÆĶõ»öºÒÀÌ ½ÇÇàÇÏÁö ¾ÊÀ¸¸é »¡°£»ö ºÒÀÌ µé¾î¿É´Ï´Ù.

¸¸¾à »¡°£»öºÒ(mysql¼­¹ö°¡ ÁßÁöÁß)À϶§ ½ÇÇà ½ÃÅ°·Á¸é Æ®·¹ÀÌ¿¡ ÀÖ´Â ½ÅÈ£µî ¾ÆÀÌÄÜÀ» ´©¸£°í
WinNT³ªWin9X¸¦ ¼±ÅÃ, start the service ¸¦ ¼±ÅÃÇÏ¸é ½ÅÈ£µî¿¡ ÆĶó»ý ºÒÀÌ µé¾î¿È.
Áï mysql¼­¹ö°¡ ½ÃÀÛÇß´Ù´Â ¸».

±×¿Ü °ü¸®¿ë ¸í·É¾îÀÎ mysqladminÀÌ ÀÖÀ½.
¼öµ¿À¸·Î ½ÇÇà½Ã¿¡´Â mysqld.exe¸¦ ½ÇÇàÇÏ¸é µÇÁö¸¸ ¼öµ¿À¸·Î stop½ÃÅ°·Á¸é mysqladminÀ» ½ÇÇà.
¹°·Ð ¿É¼Ç°úÇÔ²²...
¾Æ·¡´Â mysqladmin¿ë ¸í·É¾îÀÓ. ±â´ÉÀº ¼³¸íÀ» ÂüÁ¶.

  create databasename   Create a new database
  drop databasename     Delete a database and all its tables
  extended-status       Gives an extended status message from the server
  flush-hosts           Flush all cached hosts
  flush-logs            Flush all logs
  flush-status          Clear status variables
  flush-tables          Flush all tables
  flush-threads         Flush the thread cache
  flush-privileges      Reload grant tables (same as reload)
  kill id,id,...        Kill mysql threads
  password new-password Change old password to new-password
  ping                  Check if mysqld is alive
  processlist           Show list of active threads in server
  reload                Reload grant tables
  refresh               Flush all tables and close and open logfiles
  shutdown              Take server down
  status                Gives a short status message from the server
  variables             Prints variables available
  version               Get version info from server

À§ ¸í·É¾îÁß Æ¯È÷ ½Å°æ¾µ°ÍÀº password°ü·Ã.

¼³Ä¡ÈÄ ¹Ýµå½Ã root(MySQL DB)ÀÇ ¾ÏÈ£¸¦¼³Á¤ÇÒ°Í.  
¾ÈÇÏ¸é ºÒÇàÇÑÀÏ(DB»èÁ¦)ÀÌ ¹ß»ýÇÒ Áöµµ...   

# mysqladmin -u root password »õ¾ÏÈ£

 
1 2 3
References
 
http://www.mysql.com
http://java.sun.com/jdbc
Copyright ¨Ï 2003 www.javapattern.info & www.jlook.com, an jLOOK co.,LTD