MySQL 4.1.9 ÄÄÆÄÀÏ ¸Þ´º¾ó (Ver 1.0.1)


Official distribution site : http://jkkang.net/
Technical Info : jkkang65@hanmail.net

Last Updated in February 18th, 2005
Written by Kang Jul Ki



  º» ¹®¼­´Â Linux ȯ°æ¿¡¼­ MySQL-4.1.9À» ÄÄÆÄÀÏ¹× ÀνºÅçÇÏ´Â °úÁ¤À» ¼³¸íÇÏ´Â ¹®¼­ÀÌ´Ù. ¹®¼­´Â ÄÄÆÄÀÏ °úÁ¤À» ´Ù·ç±â ¶§¹®¿¡ »ç¿ëÀÚ°¡ µû¶ó¼­ ÇÏ´Ù°¡ ¹ß»ýÇÏ´Â ¹®Á¦¿¡ ´ëÇؼ­´Â ¾î¶² Ã¥ÀÓµµ ÇÊÀÚ°¡ ÁöÁö ¾Ê´Â´Ù.

S/WVersionºñ°í
Linux2.4.20
MySQL4.1.9
GNU gcc/g++2.96or higher
GNU make3.79.1or higher



1. MySQL 4.1.9 ÄÄÆÄÀÏ ¹× ÀνºÅç


  2005³â 2¿ù 11ÀÏ ÇöÀç 4.x¹öÀü¿¡¼­´Â MySQL-4.1.9ÀÌ °¡Àå ÃֽŠ¹öÀüÀÌ´Ù. MySQLÀÇ ¼³Ä¡ directory´Â ±âº»ÀûÀ¸·Î /usr/localÀÌ´Ù. µû¶ó¼­, ÄÄÆÄÀϽÿ¡ /usr/local/mysql¿¡ ¼³Ä¡ÇÒ°ÍÀ» °­·ÂÇÏ°Ô ±ÇÀåÇÏ´Â ¹ÙÀÌ´Ù. À̸¦ À§Çؼ­´Â configure¸¦ ½ÇÇàÇÒ ¶§ --prefix=/usr/local/mysql ¿É¼ÇÀ» ³Ö¾î ÁÖ¸é µÈ´Ù. ±×¸®°í, ÇѱÛÁö¿øÀ» À§Çؼ­ --with-charset=euckr ¿É¼Çµµ ³Ö¾îÁÖµµ·Ï ÇÏÀÚ. Mysql-4.x¹öÀü¿¡¼­´Â --with-charset=euc_krÀÌ --with-charset=euckr·Î ¹Ù²î¾úÀ¸´Ï ÁÖÀÇÇϱ⠹ٶõ´Ù.


Linux OS ¹öÀü

[root@www /usr/local] uname -a
Linux www 2.4.20 #1 Mon Apr 7 17:49:20 KST 2003 i586 unknown


MySQL °ü¸®¸¦ À§ÇÑ »ç¿ëÀÚ Ãß°¡

user Ãß°¡ : mysql (group: mysql)
group Ãß°¡: mysql
home directory: /usr/local/mysql

MySQL-4.1.9 ¾ÐÃà Ç®±â

				
[root@www /usr/local] id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)

[root@www /usr/local] ls -l mysql-4.1.9.tar.gz
-rw-r--r--    1 jkkang   jkkang   22308321 Feb  1 22:59 mysql-4.1.9.tar.gz

[root@www /usr/local] tar zxvf mysql-4.1.9.tar.gz
[root@www /usr/local] cd mysql-4.1.9

Makefile »ý¼º ¹× ÄÄÆÄÀÏ, ÀνºÅç

[root@www /usr/local/mysql-4.1.9] CC=gcc CXX=gcc ./configure --prefix=/usr/local/mysql --with-charset=euckr --without-debug
[root@www /usr/local/mysql-4.1.9] make
[root@www /usr/local/mysql-4.1.9] make install

±âº» µ¥ÀÌÅͺ£À̽º »ý¼º

[root@www /usr/local/mysql-4.1.9] ./scripts/mysql_install_db

mysql_install_db ¸í·É¾î´Â MySQLÀ» ¾÷±×·¹À̵åÇÒ¶§ ½ÇÇàÀ» ÇØÁ൵ ±âÁ¸ÀÇ ³²¾ÆÀÖ´Â tableÀº °ÇµéÁö ¾ÊÀ¸¹Ç·Î »ó°ü¾÷´Ù. ±×¸®°í À§ ¸í·É¾î ¼öÇà½Ã ÁÖÀÇÇÒÁ¡Àº ¹Ýµå½Ã À§¿Í°°ÀÌ ½ÇÇàÀ» ÇؾßÁö, scripts·Î µé¾î°¡¼­ mysql_install_db ¸í·É¾î¸¸ ¼öÇàÀ» ÇÏ¸é ¾ÈµÈ´Ù´Â °ÍÀÌ´Ù. ÀÌÀ¯´Â ½ºÅ©¸³Æ®ÀÚü¿¡ °æ·Î°¡ Á¤ÇØÁ® Àֱ⠶§¹®ÀÌ´Ù.


2. chown, chgrp ¼³Á¤Çϱâ


[root@www /] chown -R root /usr/local/mysql/.
[root@www /] chgrp -R mysql /usr/local/mysql/.
[root@www /] chown -R mysql /usr/local/mysql/var


3. cnf ÆÄÀÏ º¹»çÇϱâ


[root@www /] cd /usr/local/mysql-4.1.9
[root@www /usr/local/mysql-4.1.9] 
[root@www /usr/local/mysql-4.1.9]# cp support-files/my-medium.cnf /etc/my.cnf


4. MySQL ½ÃÀÛÇϱâ


[root@www /] su - mysql
[root@www /usr/local/mysql] cd bin
[root@www /usr/local/mysql/bin] ./mysqld_safe --user=mysql &
[root@www /usr/local/mysql/bin] ps -ef|grep mysqld
mysql    21855     1  0 17:54 pts/0    00:00:00 /bin/sh ./mysqld_safe --user=mys
mysql    21879 21855  0 17:54 pts/0    00:00:04 /usr/local/mysql/libexec/mysqld
mysql    21881 21879  0 17:54 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21882 21881  0 17:54 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21883 21881  0 17:54 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21884 21881  0 17:54 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21885 21881  0 17:54 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21888 21881  0 17:55 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21889 21881  0 17:55 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21890 21881  0 17:55 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld
mysql    21891 21881  0 17:55 pts/0    00:00:00 /usr/local/mysql/libexec/mysqld



5. MySQL Admin ¾ÏÈ£ ¼³Á¤Çϱâ


  mysqlÀ» óÀ½ »ý¼ºÇϸé admin ¿¡ ´ëÇÑ ¾ÏÈ£°¡ ¾øÀ¸¹Ç·Î ¹Ýµå½Ã ¾ÏÈ£¸¦ ¸¸µé¾îÁà¾ß ÇÑ´Ù.

* ¹æ¹ý 1
[root@www /usr/local/mysql/bin] ./mysqladmin -u root password 123456
[root@www /usr/local/mysql/bin] ./mysqladmin -u root -p reload
Enter password:
[root@www /usr/local/mysql/bin]

* ¹æ¹ý 2 (¾ÏÈ£ ¼³Á¤ÀÌ ¾ø´Â »óÅÂ)
[root@www /usr/local/mysql/bin] ./mysql -u root -p mysql
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.9-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> update user
    -> set password=password('123456')
    -> where user='root';
Query OK, 1 row affected (0.15 sec)
Rows matched: 2  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>


6. mysqlshow ¸í·É¾î »ç¿ëÇϱâ


[root@www /usr/local/mysql/bin] ./mysqlshow -u root -p mysql
Enter password:
Database: mysql
+---------------------------+
|          Tables           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+


7. mysql dabase¿¡ Á¢¼ÓÇϱâ


[root@www /usr/local/mysql/bin] mysql -u root -p mysql
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 4.1.9-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.00 sec)

mysql>


8. Database & User, Grant ¼Ó¼º(»ç¿ëÀÚ±ÇÇÑ) ¼³Á¤Çϱâ


»ç¿ëÀÚ ±ÇÇÑÀº ´ÙÀ½ÀÇ µÎ °¡Áö·Î ³ª´­¼ö ÀÖ´Ù.
1. MySQL¼­¹ö¿¡ Á¢¼ÓÇÒ ¼ö ÀÖ´Â ±â´É : user table »ç¿ë
2. °¢ DB¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Â ±â´É : db table »ç¿ë

ÇÑ°¡Áö ÁÖÀÇÇÒÁ¡Àº user table ±ÇÇÑ¿¡ 'Y'¸¦ ÁÖ¸é ±× ±ÇÇÑÀÌ Æ¯Á¤ db¿¡¸¸ ÁÖ¾îÁö´Â°ÍÀÌ ¾Æ´Ï¶ó mysql¿¡ Á¸ÀçÇÏ´Â ¸ðµç db¿¡ Àû¿ëÀÌ µÇ°ÔµÈ´Ù. µû¶ó¼­ ±ÇÇÑÀ» ¼³Á¤ÇÏ´Â mysql db±îÁöµµ Àû¿ëÀÌ µÇ¹Ç·Î, user tableÀº ¹Ýµå½Ã Á¢¼Ó¸¸ °¡´ÉÇϵµ·Ï host, user, password¸¦ Á¦¿ÜÇÑ ¸ðµç ¼³Á¤À» 'N'·Î ÁÖ°í, db table¿¡¼­ »ç¿ëÀÚ¿¡°Ô ±ÇÇѼ³Á¤À» ÇØÁִ°ÍÀÌ ¾ÈÀüÇÏ´Ù.

mysql> create database mydb;
Query OK, 1 row affected (0.01 sec)

mysql> show databases;
+----------+
| Database |
+----------+
| mydb     |
| mysql    |
| test     |
+----------+
3 rows in set (0.01 sec)

mysql>

* ÁÖÀÇ»çÇ×

»ç¿ëÀÚ¸¦ »õ·Î ¸¸µé±â À§Çؼ­´Â grant ¸í·É¾î¸¦ »ç¿ëÇÏ¸é µÈ´Ù. ƯÀÌÇÒÁ¡Àº ¾î´À °÷¿¡¼­µç ¼­¹ö¿¡ ¿¬°áÇÒ ¼ö ÀÖ´Â ¿ÏÀüÇÑ ½´ÆÛÀ¯Àú¸¦ ¸¸µé±â À§Çؼ­´Â ´ÙÀ½°ú °°ÀÌ jkkang@localhost, jkkang@"%"¸¦ »ç¿ëÇÑ GRANT ¸¦ ÀÛ¼ºÇØ Áà¾ß¸¸ ÇÑ´Ù´Â °ÍÀÌ´Ù. ±× ÀÌÀ¯´Â localhost ¸ñ·ÏÀ» Ãß°¡ÇÏÁö ¾ÊÀ¸¸é, mysql_install_db ¿¡ ÀÇÇØ »ý¼ºµÈ localhost ÀÇ ÀÍ¸í »ç¿ëÀÚ ·ÎÄà ȣ½ºÆ®¿¡¼­ Á¢¼ÓÇÒ¶§ ¿ì¼±±ÇÀ» °®°ÔµÈ´Ù. ¿Ö³ÄÇϸé ÁöÁ¤µÈ Host ÇÊµå °ªÀÌ ÀÖÀ¸¸ç Á¤·Ä ¼ø¼­¿¡¼­ ¸ÕÀú ¿À±â ¶§¹®ÀÌ´Ù. (** ½ÂÀÎ Å×À̺íÀÇ Á¤¿­ ¼ø¼­°¡ ƯÁ¤ÇÑ Host¸¦ ÁöÁ¤ÇÑ °ÍºÎÅÍ ½ÃÀÛÇÏ´Â °ÍÀ» ±â¾ïÇÏÀÚ.)

¾Æ·¡¿¡¼­ 3¹ø°ÁÙ »¡°£»öÀ¸·Î Ç¥½ÃÇÑ ¸í·É¾î±¸¹®Àº root·Î ¿ø°ÝÁ¢¼ÓÀ» Çϱâ À§ÇÑ ¸í·É¾îÀÌ´Ù. ÀÌ ÁÙÀº º¸¾È¿¡ Ãë¾àÇÒ¼ö ÀÖÀ¸¹Ç·Î »ç¿ëÇÒ°ÇÁö ¸»°ÇÁö °í·Á¸¦ ÇؾßÇÑ´Ù. phpMyAdmin°ú ÇÔ²² ¾µ´ë 3¹ø°ÁÙÀº ¾ÈÇØÁ൵ µÈ´Ù. MySQL-4.1.9 & phpMyAdmin-2.6.1°ú ¿¬µ¿ÇÒ¶§ ¿¡·¯³ª´Â ¹®Á¦´Â WWW°Ô½ÃÆÇ¿¡ ¿Ã·Á³ùÀ¸´Ï, Âü°í ¹Ù¶õ´Ù.
mysql> grant all privileges on mydb.* to jkkang@"%" identified by '123456' with grant option;
mysql> grant all privileges on mydb.* to jkkang@localhost identified by '123456' with grant option;
mysql> grant all privileges on *.* to root@'%' identified by '123456' with grant option;

Query OK, 0 rows affected (0.00 sec)

mysql> select Host, Db, User, Select_priv from db;
+------+---------+--------+-------------+
| Host | Db      | User   | Select_priv |
+------+---------+--------+-------------+
| %    | test    |        | Y           |
| %    | test\_% |        | Y           |
| %    | mydb    | jkkang | Y           |
+------+---------+--------+-------------+
3 rows in set (0.01 sec)

mysql> select Host, User, Password from user;
+-----------+--------+------------------+
| Host      | User   | Password         |
+-----------+--------+------------------+
| localhost | root   | 30f30a1207b0de9f |
| cws       | root   | 30f30a1207b0de9f |
| localhost |        |                  |
| cws       |        |                  |
| %         | jkkang | 30f30a1207b0de9f |
| localhost | jkkang | 30f30a1207b0de9f |
| %         | root   | 30f30a1207b0de9f |
+-----------+--------+------------------+

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)


9. Database »èÁ¦Çϱâ


ÀÌ ¸í·É¾î´Â Á¸ÀçÇÏ´Â ¸ðµç db ¹× °Å±â¿¡ µé¾îÀÖ´Â tableµµ »èÁ¦¸¦ ÇÑ´Ù. Çѹø »èÁ¦µÇ¸é º¹±¸°¡ ¾ÈµÇ¹Ç·Î ÁÖÀǸ¦ ¿ä±¸ÇÑ´Ù.

mysql> drop database db_name


10. »ç¿ëÀÚ ¾ÏÈ£ º¯°æÇϱâ


mysql> update user set password=password('123456) where user='jkkang';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)


11. »ç¿ëÀÚ°¡ ¸¸µç Database¿¡ Table »ý¼ºÇϱâ


$ mysql -u jkkang -p mydb
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 4.1.9-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table person (
   -> id int not null auto_increment,
   -> name varchar(10),
   -> email varchar(20),
   -> phone varchar(15),
   -> primary key (id));
Query OK, 0 rows affected (0.03 sec)

* table »èÁ¦Çϱâ
mysql> drop table table_name;

mysql> show tables;
+----------------+
| Tables_in_mydb |
+----------------+
| person         |
+----------------+
1 row in set (0.00 sec)

mysql> show columns from person;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     |      | PRI | NULL    | auto_increment |
| name  | varchar(10) | YES  |     | NULL    |                |
| email | varchar(20) | YES  |     | NULL    |                |
| phone | varchar(15) | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> insert into person values
   -> (NULL, '°­ÁÙ±â', 'jkkang65@hanmail.net', '011-093-2312');
Query OK, 1 row affected (0.01 sec)

mysql> select * from person;
+----+--------+----------------------+--------------+
| id | name   | email                | phone        |
+----+--------+----------------------+--------------+
|  1 | °­ÁÙ±â | jkkang65@hanmail.net | 011-093-2312 |
+----+--------+----------------------+--------------+
1 row in set (0.00 sec)


12. µ¥ÀÌÅͺ£À̽ºÀÇ ¹é¾÷°ú º¹±¸Çϱâ


MySQL¿¡¼­ ¹é¾÷(Database, Table)À» ÇÏ´Â ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù.


# mysqldump -u [db »ç¿ëÀÚ¸í] -p [¹é¾÷ÇÒ db] > [¿ÜºÎ·ÎÀúÀåÇÒ ÆÄÀϸí]
# mysqldump -u root -p mydb > mydb_backup.sql

MySQL¿¡¼­ ´Ù½Ã º¹±¸¸¦ ÇÒ¶§´Â ´ÙÀ½°ú °°ÀÌ ½ÇÇุ ½ÃÄÑÁÖ¸é µÈ´Ù.
# mysql -u root -p mydb < mydb_backup.sql

¸¸ÀÏ, database ¾ø´Ù°í ³ª¿À¸é ´ÙÀ½°ú °°ÀÌ ¹Ì¸® create database¸¦ ÇØÁֱ⠹ٶõ´Ù.
# mysqladmin -u root -p create mydb
Enter password:
¸¸¾à¿¡ table¸¸À» ¹é¾÷¹Þ°í ½ÍÀ¸¸é ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù.
mysql> LOCK TABLES person READ;
mysql> SELECT * INTO OUTFILE 'filename' FROM person;
º¹±¸ÇÏ°í ½ÍÀ¸¸é,
mysql> LOAD DATA INFILE 'filename' INTO TABLE person; mysql> UNLOCK TABLES;

Âü°í·Î, mysql ¹é¾÷À» ÇÒ¶§´Â ƯÁ¤ db¸¸À» ¹é¾÷¹Þ¾Æ¼­´Â Àǹ̰¡ ¾ø´Ù. Áï, mysql dbµµ ÇÔ²² ¹é¾÷À» ¹Þ¾ÆµÖ¾ß¸¸ ÇÑ´Ù. ±×·¡¾ß¸¸ ¾î¶² dbµéÀÌ ÀÖ¾ú´ÂÁö¸¦ ¾Ë¼ö Àֱ⠶§¹®ÀÌ´Ù. Ç×»ó, mysql dbµµ¹é¾÷À» ¹Þµµ·Ï ÇÏÀÚ.



13. MySQL root ¾ÏÈ£¸¦ ÀÒ¾î¹ö·ÈÀ» °æ¿ì ÇØ°áÃ¥


¸ÕÀú ½ÇÇàÁßÀÎ mysqlÀ» mysqladmin¸í·É¾î·Î Á×Àϼö°¡ ¾øÀ¸´Ï, kill ¸í·É¾î·Î ÇØ´ç processµéÀ» ¸ðµÎ Á×ÀδÙ. ±×¸®°í ´ÙÀ½°ú °°ÀÌ grant-table ¹Ì»ç¿ë¸ðµå·Î mysql¸¦ ½ÃÀÛÇÑ´Ù.

# ./mysqld_safe --skip-grant-tables &
# ./mysql -u root mysql
mysql> update user set password=password('123456') where user='root';
mysql> flush privileges;
mysql> exit;

½ÇÇàÁßÀÎ mysqlÀ» kill·Î Á×ÀδÙ.

# ./mysqld_safe --user=mysql &


14. MySQL ¼Ë´Ù¿îÇϱâ


$ mysqladmin -u root -p shutdown
Enter password:
021206 13:07:12  mysqld ended


15. ºÎÆÃÇÒ¶§ Start Çϱâ


´ÙÀ½ÀÇ Shell ÆÄÀÏÀ» »ç¿ëÇÏ¸é µÈ´Ù.

# mysql.server start
# mysql.server stop



ÈÞ ´Ù³¡³Â´Ù!!!



Copyleft (c) 1996 - 2005, Kang Jul Ki. All rights were not reserved.
Powered by http://jkkang.net since 1996