MySQL 3.23.58 ÄÄÆÄÀÏ ¸Þ´º¾ó (Ver 1.0)
|
|
º» ¹®¼´Â Linux ȯ°æ¿¡¼ MySQL-3.23.58À» ÄÄÆÄÀÏ¹× ÀνºÅçÇÏ´Â °úÁ¤À» ¼³¸íÇÏ´Â ¹®¼ÀÌ´Ù. ¹®¼´Â ÄÄÆÄÀÏ °úÁ¤À» ´Ù·ç±â ¶§¹®¿¡ »ç¿ëÀÚ°¡ µû¶ó¼ ÇÏ´Ù°¡ ¹ß»ýÇÏ´Â ¹®Á¦¿¡ ´ëÇؼ´Â ¾î¶² Ã¥ÀÓµµ ÇÊÀÚ°¡ ÁöÁö ¾Ê´Â´Ù.
|
S/W | Version | ºñ°í |
Linux | 2.4.20 | |
MySQL | 3.23.58 | |
GNU gcc/g++ | 2.96 | or higher |
GNU make | 3.79.1 | or higher |
|
|
1. MySQL 3.23.58 ÄÄÆÄÀÏ ¹× ÀνºÅç
|
2003³â 11¿ù 28ÀÏ ÇöÀç 3.x¹öÀü¿¡¼´Â MySQL-3.23.58ÀÌ °¡Àå ÃֽŠ¹öÀüÀÌ´Ù. º» ¹®¼¿¡¼´Â MySQL-4.x´Â ´Ù·çÁö ¾Ê¾ÒÁö¸¸, ¹æ¹ýÀº ºñ½ÁÇÏ´Ù. MySQLÀÇ ¼³Ä¡ directory´Â ±âº»ÀûÀ¸·Î /usr/localÀÌ´Ù. µû¶ó¼, ÄÄÆÄÀϽÿ¡ /usr/local/mysql¿¡ ¼³Ä¡ÇÒ°ÍÀ» °·ÂÇÏ°Ô ±ÇÀåÇÏ´Â ¹ÙÀÌ´Ù. À̸¦ À§Çؼ´Â configure¸¦ ½ÇÇàÇÒ ¶§ --prefix=/usr/local/mysql ¿É¼ÇÀ» ³Ö¾î ÁÖ¸é µÈ´Ù. ±×¸®°í, ÇѱÛÁö¿øÀ» À§Çؼ --with-charset=euc_kr ¿É¼Çµµ ³Ö¾îÁÖµµ·Ï ÇÏÀÚ.
|
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-3.23.58 ¾ÐÃà Ç®±â
|
[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 ~jkkang/down/mysql-3.23.58.tar.gz
-rw-r--r-- 1 jkkang jkkang 12039843 Sep 22 17:26 mysql-3.23.58.tar.gz
[root@www /usr/local]# tar zxvf mysql-3.23.58.tar.gz
[root@www /usr/local]# cd mysql-3.23.58
|
Makefile »ý¼º ¹× ÄÄÆÄÀÏ, ÀνºÅç
|
[root@www /usr/local/mysql-3.23.58]# ./configure --prefix=/usr/local/mysql --with-charset=euc_kr
[root@www /usr/local/mysql-3.23.58]# make
[root@www /usr/local/mysql-3.23.58]# make install
|
±âº» µ¥ÀÌÅͺ£À̽º »ý¼º
|
[root@www /usr/local/mysql-3.23.58]# ./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-3.23.58
[root@www /usr/local/mysql-3.23.58]#
[root@www /usr/local/mysql-3.23.58]# 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]# ./safe_mysqld --user=mysql &
[root@www /usr/local/mysql/bin]# ps -ef|grep mysqld
mysql 632 593 1 21:15 pts/0 00:00:00 /bin/sh ./safe_mysqld --user=mys
mysql 648 632 2 21:15 pts/0 00:00:00 /usr/local/mysql/libexec/mysqld
mysql 650 648 0 21:15 pts/0 00:00:00 /usr/local/mysql/libexec/mysqld
mysql 651 650 0 21:15 pts/0 00:00:00 /usr/local/mysql/libexec/mysqld
mysql 653 593 0 21:16 pts/0 00:00:00 grep 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
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 3.23.58-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 |
| host |
| tables_priv |
| 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: 3.23.58-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¸¦ ÁöÁ¤ÇÑ °ÍºÎÅÍ ½ÃÀÛÇÏ´Â °ÍÀ» ±â¾ïÇÏÀÚ.)
|
|
9. Database »èÁ¦Çϱâ
|
mysql> drop database db_name
|
ÀÌ ¸í·É¾î´Â Á¸ÀçÇÏ´Â ¸ðµç db ¹× °Å±â¿¡ µé¾îÀÖ´Â tableµµ »èÁ¦¸¦ ÇÑ´Ù. Çѹø »èÁ¦µÇ¸é º¹±¸°¡ ¾ÈµÇ¹Ç·Î ÁÖÀǸ¦ ¿ä±¸ÇÑ´Ù.
|
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;
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 |
+-----------+--------+------------------+
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
|
|
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 22 to server version: 3.23.58-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¿¡¼ ¹é¾÷À» ÇÏ´Â ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù.
|
# 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:
Âü°í·Î, mysql ¹é¾÷À» ÇÒ¶§´Â ƯÁ¤ db¸¸À» ¹é¾÷¹Þ¾Æ¼´Â Àǹ̰¡ ¾ø´Ù. Áï, mysql dbµµ ÇÔ²² ¹é¾÷À» ¹Þ¾ÆµÖ¾ß¸¸ ÇÑ´Ù. ±×·¡¾ß¸¸ ¾î¶² dbµéÀÌ ÀÖ¾ú´ÂÁö¸¦ ¾Ë¼ö Àֱ⠶§¹®ÀÌ´Ù. Ç×»ó, mysql dbµµ¹é¾÷À» ¹Þµµ·Ï ÇÏÀÚ.
|
|
13. MySQL root ¾ÏÈ£¸¦ ÀÒ¾î¹ö·ÈÀ» °æ¿ì ÇØ°áÃ¥
¸ÕÀú ½ÇÇàÁßÀÎ mysqlÀ» mysqladmin¸í·É¾î·Î Á×Àϼö°¡ ¾øÀ¸´Ï, kill ¸í·É¾î·Î ÇØ´ç processµéÀ» ¸ðµÎ Á×ÀδÙ. ±×¸®°í ´ÙÀ½°ú °°ÀÌ grant-table ¹Ì»ç¿ë¸ðµå·Î mysql¸¦ ½ÃÀÛÇÑ´Ù.
|
# ./safe_mysqld --skip-grant-tables &
# ./mysql -u root mysql
mysql> update user set password=password('123456') where user='root';
mysql> flush privileges;
mysql> exit;
½ÇÇàÁßÀÎ mysqlÀ» kill·Î Á×ÀδÙ.
# ./safe_mysqld --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
|
ÈÞ ´Ù³¡³Â´Ù!!!
|
|