How to Install MySQL 4.1.22 on FreeBSD 5.x or 6.x

I needed to install MySQL 4.1.x on my FreeBSD machine at home and wanted to do it the quickest way. I Google’d and noticed a lot of outdated information (going back to MySQL 3.x versions!). Anyway, here’s the latest way to install MySQL on a FreeBSD system. I tested this on 6.2-STABLE and it worked flawlessly. Make sure your ports system is up to date. At the time of this writing, the MySQL version in the 4.x branch is 4.1.22. I know that 5.x is out, but this is my test server compared to my production server that runs 4.1.22 as well.

Type in the following commands as root:

cd /usr/ports/databases/mysql41-server/
make install clean
/usr/local/bin/mysql_install_db
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
/usr/local/etc/rc.d/mysql-server start
/usr/local/bin/mysqladmin -u root password newpassword

Now, edit /etc/rc.conf and add the following line:

mysql_enable=”YES”

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *