หลังจากติดตั้ง FreeBSD , Update and Applying Security Patches เพื่อแก้ไขข้อบกพร่องต่างๆและ Update Ports แล้ว เรามาดูขั้นตอนการติดตั้ง MySQL 5.1 กันครับ โดยเริ่มที่
# cd /usr/ports/databases/mysql51-server
สำหรับ charset utf8
# make WITH_CHARSET=utf8 WITH_XCHARSET=all WITH_COLLATION=utf8_general_ci WITH_OPENSSL=yes BUILD_OPTIMIZED=yes WITH_ARCHIVE=yes WITH_FEDERATED=yes WITH_NDB=yes install cleanสำหรับ charset tis620
#make WITH_CHARSET=tis620 WITH_XCHARSET=all WITH_COLLATION=tis620_thai_ci WITH_OPENSSL=yes BUILD_OPTIMIZED=yes WITH_ARCHIVE=yes WITH_FEDERATED=yes WITH_NDB=yes install clean
หลังจากติดตั้งเสร็จเรียบร้อย ทำการกำหนดให้ MySQL ทำงานทุกครั้งตอนบูตเครื่อง โดยแก้ไขไฟล์ /etc/rc.conf แล้วเพิ่มคำสั่งนี้เข้าไป
mysql_enable=”YES”
หรือใช้คำสั่งนี้
# echo ‘mysql_enable=”YES”‘ >> /etc/rc.conf
เลือกไฟล์คอนฟิกให้เหมาะสมกับเครื่องเซิร์ฟเวอร์
# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
# chown mysql:mysql /etc/my.cnf
# chmod 644 /etc/my.cnf
สตาร์ท MySQL Server ให้ทำงาน และกำหนดรหัสผ่านให้กับ root
# /usr/local/etc/rc.d/mysql-server start
กำหนดรหัสผ่านให้กับ root
# /usr/local/bin/mysqladmin -u root password ‘?????????‘
# rehash
ทดสอบเข้าใช้งาน
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.58-log FreeBSD port: mysql-server-5.1.58
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
mysql> status;
————–
mysql Ver 14.14 Distrib 5.1.58, for portbld-freebsd8.2 (i386) using 5.2
Connection id: 2
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: more
Using outfile: ”
Using delimiter: ;
Server version: 5.1.58-log FreeBSD port: mysql-server-5.1.58
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 3 min 50 sec
Threads: 1 Questions: 8 Slow queries: 0 Opens: 15 Flush tables: 1 Open tabl es: 8 Queries per second avg: 0.34
————–
mysql>
ออกจาก MySQL ด้วยคำสั่ง
quit; หรือ \q
เสร็จละครับ!!









