Advertisement

SharingMatrix.com - Free, simple and fast file hosting!

Selasa, 08 Juni 2010

Install MySQL server di Mac Leopard

Dengan menggunakan MacBook bukan merupakan kendala dalam pengembangan aplikasi berbasiskan Web.

Untuk fungsi sebagai personal server MacBook tidak ketinggalan dengan kemampuannya yang sama dengan linux, hanya saja untuk mempermudah instalasinya dibutuhkan Darwinports.

Dengan terpasangnya darwinports, maka yang dibutuhkan untuk mengembangkan aplikasi web si MacBook yaitu :

  1. Webserver
    Untuk webserver sudah menjadi buildin dengan Mac, tinggal mengaktifkan saja, yaitu dari Finder + Application + System Preferences + Sharing + Web Sharing.
    Webserver yang dipakai yaitu Apache2, sehingga konfigurasi dan operasionalisasinya pada prinsipnya sama dengan apache pada umumnya.
    Berikut beberapa fungsi yang dapat dipanggil secara manual/remote lewat terminal:
    a. Menjalankan apache
    # service org.apache.httpd [start/stop]
    b. File konfigurasi php di “/etc/apache2/httpd.conf”
    c. Bila PHP belum aktif, silahkan edit file konfigurasi dan aktifkan baris module yang sudah tersedia
    LoadModule php5_module libexec/apache2/libphp5.so
  2. MySQL database
    MySQL tidak terinstall di Mac Leopard, sehingga harus diinstall sendiri, yaitu dengan cara sebagai berikut :
    # sudo port install mysql5
    … otomatis download & install mysql

    Tahapan berikutnya mengaktifkan mysql server dengan cara :
    a. buat konfigurasi my.cnf
    # sudo cp /opt/local/share/mysql5/mysql/my-small.cnf /etc/my.cnf

    b. Dilakukan editing agar isi my.cnf sesuai dengan MacBook

    # Example MySQL config file for small systems.
    #
    # This is for a system with little memory (<= 64M) where MySQL is only used # from time to time and it’s important that the mysqld daemon # doesn’t use much resources. # # You can copy this file to # /opt/local/etc/mysql5/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options (in this # installation this directory is /opt/local/var/db/mysql5) or # ~/.my.cnf to set user-specific options. # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the “–help” option.

    # The following options will be passed to all MySQL clients
    [client]
    #password = your_password
    port = 3306
    #socket = /opt/local/var/run/mysql5/mysqld.sock
    socket = /var/run/mysql5/mysqld.sock

    # Here follows entries for some specific programs

    # The MySQL server
    [mysqld]
    port = 3306
    #socket = /opt/local/var/run/mysql5/mysqld.sock
    socket = /var/run/mysql5/mysqld.sock
    pid-file = /var/run/mysqld.pid
    log-error = /var/log/mysqld.log

    skip-locking
    key_buffer = 16K
    max_allowed_packet = 1M
    table_cache = 4
    sort_buffer_size = 64K
    read_buffer_size = 256K
    read_rnd_buffer_size = 256K
    net_buffer_length = 2K
    thread_stack = 128K
    user=root

    # Don’t listen on a TCP/IP port at all. This can be a security enhancement,
    # if all processes that need to connect to mysqld run on the same host.
    # All interaction with mysqld must be made via Unix sockets or named pipes.
    # Note that using this option without enabling named pipes on Windows
    # (using the “enable-named-pipe” option) will render mysqld useless!
    #
    #skip-networking
    server-id = 1

    # Uncomment the following if you want to log updates
    #log-bin=mysql-bin

    # Disable Federated by default
    skip-federated

    # Uncomment the following if you are NOT using BDB tables
    #skip-bdb

    # Uncomment the following if you are using InnoDB tables
    innodb_data_home_dir = /opt/local/var/db/mysql5/
    innodb_data_file_path = ibdata1:10M:autoextend
    innodb_log_group_home_dir = /opt/local/var/db/mysql5/
    innodb_log_arch_dir = /opt/local/var/db/mysql5/
    # You can set .._buffer_pool_size up to 50 - 80 %
    # of RAM but beware of setting memory usage too high
    innodb_buffer_pool_size = 16M
    #innodb_additional_mem_pool_size = 2M
    # Set .._log_file_size to 25 % of buffer pool size
    innodb_log_file_size = 5M
    innodb_log_buffer_size = 8M
    innodb_flush_log_at_trx_commit = 1
    innodb_lock_wait_timeout = 50

    [mysqldump]
    quick
    max_allowed_packet = 16M
    [mysql]
    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates

    [isamchk]
    key_buffer = 8M
    sort_buffer_size = 8M

    [myisamchk]
    key_buffer = 8M
    sort_buffer_size = 8M

    [mysqlhotcopy]
    interactive-timeout

    c. Salin script untuk start/stop service mysqlserver
    # sudo cp /opt/local/share/mysql5/mysql/mysql.server /sbin/

    d. Inisialisasi database pertamakali
    # sudo mysql_install_db5

    Installing MySQL system tables…
    090805 14:52:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to 4294967295
    090805 14:52:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to 4294967295
    090805 14:52:19 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
    OK
    Filling help tables…
    090805 14:52:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to 4294967295
    090805 14:52:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to 4294967295
    090805 14:52:19 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
    OK

    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:
    /opt/local/lib/mysql5/bin/mysqladmin -u root password ‘new-password’
    /opt/local/lib/mysql5/bin/mysqladmin -u root -h prayitna-kuswidiantas-macbook.local password ‘new-password’

    Alternatively you can run:
    /opt/local/lib/mysql5/bin/mysql_secure_installation

    which will also give you the option of removing the test
    databases and anonymous user created by default. This is
    strongly recommended for production servers.

    See the manual for more instructions.

    You can start the MySQL daemon with:
    cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl
    cd mysql-test ; perl mysql-test-run.pl

    Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

    The latest information about MySQL is available on the web at
    http://www.mysql.com
    Support MySQL by buying support/licenses at http://shop.mysql.com

    e. Start MySQL
    # mysql.server start

    f. Setup kompatibilitas dengan linux lainnya, dimana socket berada di /var/mysql
    # sudo mkdir /var/mysql
    # sudo ln -s /var/run/mysql5/mysql.sock /var/mysql/mysql.sock

  3. IDE Pemrograman
    Untuk IDE pemrograman bisa digunakan Aptana (Free).

Tidak ada komentar:

Posting Komentar