The tutorial describes how to install Apache 2.2, MySQL 5 and PHP 5 in FreeBSD 6.0 for a reliable web server.

Part 3 – Installing MySQL Server 5 with FreeBSD Ports Collection

Articles in the Series

  1. Installing FreeBSD 6.0 with Ports Collection Updating
  2. Post-Installation Configuration Tasks of FreeBSD 6.0
  3. Installing MySQL Server 5 with FreeBSD Ports Collection (This Article)
  4. Installing Apache HTTPD Web Server 2.2
  5. Installing PHP Hypertext Preprocessor Scripting Language 5 and PHP 5 Extensions
  1. Login to the FreeBSD system as root, or su – root to get to super user environment.
  2. Enter the following commands at FreeBSD command line interface (CLI) (Wait till each command to finish processing before running the next command):
    cd /usr/ports/databases/mysql50-server
    make install clean
    mysql_install_db --user=mysql
    chown -R mysql /var/db/mysql/
    chgrp -R mysql /var/db/mysql/
    /usr/local/bin/mysqld_safe -user=mysql &

    Note: If you encounter Command not found error, use command rehash to update OS path environment variables.

  3. The port installation will put a script file mysql-server.sh in /usr/local/etc/rc.d which will has capability to start MySQL server. To enable MySQL server to start automatically after every FreeBSD server reboot, enter the following command in CLI:
    echo 'mysql_enable="YES"' >> /etc/ rc.conf
  4. By default, MySQL default super user account – root – has no password (blank password). So it’s important to assign the administrator account password. To change the password to root user, enter the following command:
    mysqladmin -u root password newpassword

    Replace newpassword with your own desired password.

  5. Optionally, copy either my-huge.cnf, my-large.cnf, my-medim.cnf, my-small.cnf or my-innodb-heavy-4G.cnf (depending on the usage and utilization of MySQL server) as my.cnf to /var/db/mysql which will enable you to tweak and change the configuration of server-specific MySQL server options by editing the file.
  6. MySQL 5.0 installation done.