การติดตั้งและปรับแต่ง MySQL Database Server บน Linux Fedora Core 6
![]() |
MySQL เป็นฐานข้อมูลที่ได้รับความนิยมกันอย่างแพร่หลาย เนื่องจากมีความเร็ว ขนาดของโปรแกรมเล็ก มีเสถียรภาพ และความทนทานในการทำงานสูง อีกทั้งยังสามารถทำงานได้หลายแพลตฟอร์ม (Platform) บ่อยครั้งที่เราจะเห็นเว็บเซิร์ฟเวอร์ส่วนใหญ่ ที่ติดตั้ง Linux จะต้องรองรับภาษา PHP และสามารถใช้งานฐานข้อมูล MySQL ได้ ซึ่งเราจะเรียกระบบแบบนี้ว่า LAMP ( Linux Apache MySQL PHP ) ซึ่งเราจะได้มีการปรับแต่งในเรื่องถัดไป |
ขั้นตอนการติดตั้ง MySQL บน Fedora Core 6
ขั้นตอนที่ 1
ใส่แผ่น CD/DVD ของ Fedora Core 6 Linux แล้วทำการเมาท์ แล้วไปยังพาธที่เก็บไฟล์สำหรับติดตั้งซอฟต์แวร์ ดังนี้
| [root@web ~]# mount /dev/cdrom /mnt/cdrom mount: block device /dev/cdrom is write-protected, mounting read-only [root@web ~]# cd /mnt/cdrom/Fedora/RPMS/ [root@web RPMS]# |
ขั้นตอนที่ 2
ทำการตรวจสอบว่า มีการติดตั้ง mysql-server ไว้แล้วหรือยัง โดยใช้คำสั่งดังนี้
|
[root@web ~]# rpm -qa | grep mysql-server |
ซึ่งในที่นี้มีการติดตั้งไว้แล้ว สามารถข้ามขั้นตอนไปยังการปรับแต่ง MySQL Database Server ได้เลย แต่ถ้ายังไม่มี ก็ทำการติดตั้งโดยใช้คำสั่ง rpm ซึ่งซอฟต์แวร์สำหรับติดตั้ง MySQL Server จะมีด้วยกันหลายไฟล์ แต่ทั้งหมดอยู่ในแผ่น Fedora Core 6 ไฟล์ต่างๆ มีดังนี้ mysql-5.0.22-2.1.i386.rpm , mysql-server-5.0.22-2.1.i386.rpm , perl-DBD-MySQL-3.0007-1.fc6.i386.rpm , perl-DBI-1.52-1.fc6.i386.rpm วิธีการติดตั้งสามารถทำได้ดังนี้
| [root@web RPMS]# rpm -ihv mysql-5.0.22-2.1.i386.rpm mysql-server-5.0.22-2.1.i386.rpm perl- DBD-MySQL-3.0007-1.fc6.i386.rpm perl-DBI-1.52-1.fc6.i386.rpm warning: mysql-5.0.22-2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2 Preparing... ########################################### [100%] 1:perl-DBI ########################################### [ 25%] 2:mysql ########################################### [ 50%] 3:perl-DBD-MySQL ########################################### [ 75%] 4:mysql-server ########################################### [100%] |
การปรับแต่ง MySQL Database Server
ไฟล์คอนฟิกหลักของ MySQL จะอยู่ที่ /etc/my.cnf ซึ่งเราควรจะปรับแต่งให้เหมาะสมกับเครื่องที่เรากำลังติดตั้ง โดยจะมีไฟล์ต้นแบบอยู่ที่ /usr/share/doc/mysql-server-5.0.22 มีไฟล์ต่างๆ ดังนี้
● my-innodb-heavy-4G.inf สำหรับเครื่องที่มีหน่วยความจำ 4 GB ใช้ engine InnoDB
● my-huge.inf สำหรับเครื่องที่มีหน่วความจำ 1-2 GB
● my-large.cnf สำหรับเครื่องที่มีหน่วความจำ 512 MB
● my-medium.cnf สำหรับเครื่องที่มีหน่วความจำ 32-64 MB หรือถ้ามีการติดตั้ง Web Server ด้วยก็ 128 MB
● my-small.cnf สำหรับเครื่องที่มีหน่วยความจำน้อยกว่า 64 MB
ในที่นี้ติดตั้ง MySQL Server ที่เครื่องคอมพิวเตอร์ที่มีหน่วยความจำ 512 MB จึงทำการเลือก mylarge.cnf เป็นต้นแบบ ซึ่งสามารถคัดลอกได้ดังนี้
| [root@web ~]# cp /usr/share/doc/mysql-server-5.0.22/my-large.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf'? y |
ตรวจสอบการทำงานของ MySQL
ทำการตรวจสอบโดยให้เซอร์วิสที่ชื่อว่า mysqld ทำการ start , stop , restart เพื่อตรวจสอบว่าสามารถใช้งานได้
| # /etc/init.d/mysqld start # /etc/init.d/mysqld stop # /etc/init.d/mysqld restart |
ตั้งรหัสผ่านให้กับผู้ใช้ Root ของ MySQL
ผู้ใช้ root ของ mysql จะเป็นคนละส่วนกับ ผู้ใช้ root ของระบบ แต่มีความหมายเดียวกันคือ คนมีสิทธิ์ในระบบฐานข้อมูลทั้งหมด สามารถกำหนดรหัสผ่านได้ โดยใช้คำสั่ง mysqladmin ดังนี้
| [root@web ~]# mysqladmin -u root password ใส่รหัสผ่านลงไป |
ล็อกอินเข้าสู่ MySQL Server แบบบรรทัดคำสั่ง
ในการล็อกอินเข้าสู่ระบบโดยผ่านทางบรรทัดคำสั่ง จะใช้คำสั่งว่า mysql ตามด้วยพารามิเตอร์ -u เพื่อระบุผู้ใช้งานที่จะเข้าใช้ แล้วตามด้วยพารามิเตอร์ -p เพื่อระบุว่ามีการใส่รหัสผ่านด้วย ดังนี้
|
root@web ~]# mysql -u root -p |
เมื่อระบบสามารถทำงานได้ปกติแล้ว กำหนดให้ mysql ทำงานทุกครั้งที่เริ่มต้นระบบ ดังนี้
[root@web ~]# chkconfig mysqld on
- Add new comment






- 3829 reads




vq1oqv kgrfypgxnjdi,
vq1oqv kgrfypgxnjdi, [url=http://wayliuznqonx.com/]wayliuznqonx[/url], [link=http://tmwbwnzgemss.com/]tmwbwnzgemss[/link], http://lkdzgscrilqt.com/
comment4, exercise bands,
comment4, exercise bands, uloyvu, paterson cloud bands, yzv, orchestras, symphonies, & bands, wry, heavy metal bands, haccmu, list of rock bands on tour, 665, wrist bands, %-P, rattlesnake skin hat bands, cclk,
comment2, magnetic sports
comment2, magnetic sports bands, 4093, marathon watch bands, 85765, british bands, :(((, tag replacement bands, ufg, gothic bands, 8DD, womans white gold wedding bands, leir, new rock bands, >:-OO,
comment5, breastfeeding
comment5, breastfeeding support vancouver, :-DDD, drinking and breastfeeding, iqafa, breastfeeding taller, 92472, breastfeeding mother's nutrition, xuwmyl, extreme breastfeeding, 8-[, sea to sky breastfeeding support, :), breastfeeding quotes, >:-),
comment6, men breastfeeding
comment6, men breastfeeding from women, dmrp, breastfeeding and arousal, tbwomm, baby thick leg breastfeeding, =PP, breastfeeding and caffeine, dbg, breastfeeding and rash, =-PP, forcing girlfriend to induce breastfeeding, eqs, breastfeeding sudafed side effects, =-D,
comment1, australian gun
comment1, australian gun laws, 4489, australian aboriginal assimilation, :-(((, australian gold gel w/ bronzer spf15 8 oz. spray, 341434, australian shepherd training, wuwovn, australian shepherds for sale phoenix, 095, australian photography, unk, australian box jellyfish, =)),
comment6, government
comment6, government inventory management, zgkw, fallout 2 inventory editor, 901, vw excess parts inventory auction, %-DD, standard cost, inventory, fobpil, consolidating class c commodity inventory, >:-OO, inventory efficiency, ydc, how to go out of business and sell your inventory, :[[,
comment2, howard community
comment2, howard community college, 8))), metro community college, 8-), health insurance community rated michigan, 527, definition of community, 527678, building community organizations, qxlwzr, tunxis community college, 72949, webshots community chicks, :PPP,
comment3, community sites,
comment3, community sites, 8-]]], webshots community lingerie, 55794, los rios community college, xuhvt, nc community colleges, tco, combined community codec pack, 153197, madisonville community college, %-), volunteer state community college, 86224,
comment3, pen pal in us
comment3, pen pal in us military, 020567, email pen pals, 2659, mont blanc fountain pen, 3968, parker pen company, qbuvro, pen pals in prison, mdbv, pen making jigs, 51078, pen gun plans, yjlx,