Getting MySQL to run on FreeBSD 7.0

During my server migration, I decided that I was going to switch from five or six random Linux distributions to using a single operating system. My place of employment seems to have a fondness for FreeBSD so I decided to give it a whirl. Although very similar to the several Linux distributions I use, FreeBSD has some differences. First installing software, I have finally gotten accustom to apt-get on the Debian based distributions I use as well as YUM (Which is on the RedHat Linux variants) because FreeBSD uses an entirely different package management system I had to learn something new. (Which is always a good thing)

FreeBSD uses two different methods. I am going to focus on the Ports collection since this way seems to be the most flexible, I must warn you though, compiling everything can become a pain in the neck if you have a slow machine. Fortunately for me, all of the servers I am using in the Server Migration are new and quite fast.

The Ports collection is relatively easy to use. Simply go into the ports collection.


server# cd /usr/ports

Now you will need to find the package you want to install (I will forgo the instructions on how to do this, as I am assuming that you know how to do that already.) In my case I started with MySQL 5

server# cd databases/mysql50-server
server# make install clean
server# mysql_install_db
server# chown -R mysql:mysql /var/db/mysql
server# /usr/local/bin/mysqld_safe -user=mysql&
server# mysqladmin -u root password <password>
server# vi /etc/rc.conf

Now you will need to tell the server to automatically start the MySQL daemon when the computer restarts. Add the following line to your rc.conf file (Which you will be editing if you have followed the previous steps.)

mysql_enable=”yes”

There you go, as long as no error messages show up, your MySQL 5.0 server will be running and will be usable.

Leave a Reply


Switch to our mobile site