ตัวอย่างการติดตั้ง MySQL 5.0 บน ubuntu 5.10

โดย อดิศร  ขาวสังข์
เขียนเมื่อ 13/12/2548
ควรจะดูข้อมูลเพิ่มเติมที่ : http://www.ubuntuguide.org/

บทนำ
MySQL 5 ได้มีการเพิ่มความสามารถขึ้นมาหลายอย่างเช่น :

  • ACID Transaction (Automic, Consistent, Isolated, Durable)
  • Stored Procedure
  • Trigger
  • View
  • Information Schema
  • Distributed Transaction (XA)

ขั้นตอนการติดตั้ง

  1. เพิ่มแหล่งข้อมูลในไฟล์ /etc/apt/sources.list ดังนี้ :

    deb http://packages.dotdeb.org stable all
    deb-src http://packages.dotdeb.org stable all


  2. ทำการอัพเดตฐานข้อมูลโปรแกรม ด้วยคำสั่งดังนี้ :

    $ sudo apt-get update

    ดูผลตามรูป




  3. ทำการติดตั้งโปรแกรม MySQL 5.0 ด้วยคำสั่งดังนี้ :

    $ sudo apt-get install mysql-server-5.0

    ซึ่งอาจจะได้ผลดังต่อไปนี้

    ksorn@sorn-mit:~$ sudo apt-get install mysql-server-5.0
    Reading package lists... Done
    Building dependency tree... Done
    The following extra packages will be installed:
    libmysqlclient15 mysql-client-5.0 mysql-common
    The following packages will be REMOVED:
    mysql-client
    The following NEW packages will be installed:
    libmysqlclient15 mysql-client-5.0 mysql-server-5.0
    The following packages will be upgraded:
    mysql-common
    1 upgraded, 3 newly installed, 1 to remove and 2 not upgraded.
    Need to get 24.9MB of archives.
    After unpacking 54.7MB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    WARNING: The following packages cannot be authenticated!
    mysql-common libmysqlclient15 mysql-client-5.0 mysql-server-5.0
    Install these packages without verification [y/N]? y
    Get:1 http://packages.dotdeb.org stable/all mysql-common 5.0.16-0.dotdeb.1 [38.0 kB]
    Get:2 http://packages.dotdeb.org stable/all libmysqlclient15 5.0.16-0.dotdeb.1 [ 1343kB]
    Get:3 http://packages.dotdeb.org stable/all mysql-client-5.0 5.0.16-0.dotdeb.1 [ 6312kB]
    Get:4 http://packages.dotdeb.org stable/all mysql-server-5.0 5.0.16-0.dotdeb.1 [ 17.2MB]
    Fetched 24.9MB in 2m12s (189kB/s)

    Preconfiguring packages ...
    (Reading database ... 58087 files and directories currently installed.)
    Removing mysql-client ...
    (Reading database ... 58047 files and directories currently installed.)
    Preparing to replace mysql-common 4.0.24-10ubuntu2 (using .../mysql-common_5.0.1 6-0.dotdeb.1_all.deb) ...
    Unpacking replacement mysql-common ...
    Selecting previously deselected package libmysqlclient15.
    Unpacking libmysqlclient15 (from .../libmysqlclient15_5.0.16-0.dotdeb.1_i386.deb ) ...
    Selecting previously deselected package mysql-client-5.0.
    Unpacking mysql-client-5.0 (from .../mysql-client-5.0_5.0.16-0.dotdeb.1_i386.deb ) ...
    Selecting previously deselected package mysql-server-5.0.
    Unpacking mysql-server-5.0 (from .../mysql-server-5.0_5.0.16-0.dotdeb.1_i386.deb ) ...
    Setting up mysql-common (5.0.16-0.dotdeb.1) ...
    Installing new version of config file /etc/mysql/my.cnf ...
    Setting up libmysqlclient15 (5.0.16-0.dotdeb.1) ...

    Setting up mysql-client-5.0 (5.0.16-0.dotdeb.1) ...
    Setting up mysql-server-5.0 (5.0.16-0.dotdeb.1) ...
    Installing new version of config file /etc/init.d/mysql ...
    Installing new version of config file /etc/logrotate.d/mysql-server ...
    Installing new version of config file /etc/mysql/debian-start ...
    Installing new version of config file /etc/mysql/debian-log-rotate.conf ...
    Installing new version of config file /etc/cron.daily/mysql-server ...
    Stopping MySQL database server: mysqld.
    Starting MySQL database server: mysqld.
    Checking for crashed MySQL tables in the background.


  4. ลองทดสอบใช้งาน MySQL 5.0 ได้ดังรูป :



  5. เพื่อความปลอดภัยควรกำหนดรหัสผ่านของ root ได้ดังรูป :



  6. ถ้าต้องการจะใ้ช้งานโปรแกรม MySQL Control Center ก็สามารถติดตั้งได้ดังนี้
    1. ติดตั้งโปรแกรมด้วยคำสั่งดังนี้ :

      $ sudo apt-get install mysqlcc

      อาจจะได้ผลดังรูป :



    2. สร้างไฟล์ควบคุมการทำงานของ MySQL Control Center ผ่าน Desktop คือไฟล์ /usr/share/applications/MySQLCC.desktop ด้วย Text Editor ซึ่งอาจจะสร้างด้วยโปรแกรม gedit (ใช้โปรแกรมอื่นเช่น vi ก็ได้) ด้วยคำสั่งดังนี้ :

      $ sudo gedit /usr/share/applications/MySQLCC.desktop

      แล้วให้เพิ่มข้อความต่อไปนี้ลงไปในไฟล์ใหม่ดังกล่าว :

      [Desktop Entry]
      Name=MySQLCC
      Comment=MySQLCC
      Exec=mysqlcc
      Icon=/usr/share/pixmaps/mysqlcc.xpm
      Terminal=false
      Type=Application
      Categories=Application;System;


      ซึ่งคำสั่งข้างบนจะเปิดโปรแกรม gedit ขึ้นมาดังรูป :



    3. บันทึกไฟล์ดังกล่าว
    4. เปิดโปรแกรม MySQL Control Center ได้จากเมนู Applications -> System tools -> MySQLCC ซึ่งจะได้ผลดังรูป :



    5. แต่ก่อนที่จะใช้งานได้ดังรูปข้างบนต้องมีการกำหนดชื่อ host , user และ password ให้ตรงกับ MySQL ก่อน ดังรูป :


จบครับ