
Druidsys.com's collection of guides related to the FreeBSD operating system.

One of the good habits of the security aware administrator is to regularly change password on critical system accounts. If you have a MySQL Server installed, then the MySQL root account definately belongs in this group.
During the installation of MySQL Server you (hopefully) changed the default password from *blank* into something more hard to guess. You did this with this command:
# mysqladmin -u root -p new_password
In order to change password you simply do the same only that you need to verify the change with the current password.
# mysqladmin -u root -p new_password
Enter password: old_password
dfThe df utility displays statistics about the amount of free disk space on the file system. The -h switch will show free space in B/M/G (for byte, megabyte and gigabyte).
freebsd-updateThis handy command is used to update FreeBSD.
Use man freebsd-update in order to get more detailed information if you like this command (I hope you do).
freebsd-update fetch
Fetches all binary updates for the current installation, including security patches.
freebsd-update upgrade
Fetches all the files that are necessary for upgrading to a new release.
WARNING! Before you run this and follow by freebsd-update install, be sure to read the release notes in case there are other steps you need to take before this upgrade.
freebsd-update install
Install the most recently fetched updates or upgrade.
freebsd-update rollback
Uninstalls the most recently installed updates.
Tips: I add freebsd-update fetch and freebsd-update install to my crontab with a two hour space once every 24 hrs. This keeps my system patched and up to date.
fsckThe fsck utility invokes file system-specific programs to check the special devices listed in the fstab(5) file or in the command line for consistency.
rehashUpdates FreeBSD's path environment variables. For instance when you have installed software you may not be able to run the executables without specifying the path. rehash solves your problem most of the times.
topDisplay and update information about the top cpu processes.
wgetGNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.
You can use it to get your external IP: wget -O - -q icanhazip.com
Remember to install the FreeBSD Ports Collection.

First you need to login as root or run su in order to get the required permissions.
Then navigate to the ports folder for MySQL:
cd /usr/ports/databases/mysql50-server
Now run:
make install clean
in order to download and install MySQL.
Once the install is finished we install the databases by running:
mysql_install_db --user=mysql
If you get an error, run rehash in order to update FreeBSD's path environment variables.
Once this is done we want to grant permissions to the mysql user in /var/db/mysql.
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
Now we can start MySQL by running:
/usr/local/bin/mysqld_safe -user=mysql &
Since we probably want MySQL to start after a reboot we will drop a line to /etc/rc.conf
echo 'mysql_enable="YES"' >> /etc/rc.conf
By default MySQL's root account has no password, so we need to change it (If we want our system to be somewhat secure). To change the password for root we enter the following command:
mysqladmin -u root password newpassword
...where newpassword is the password of our choice.
Now we can start making use of our new database server.
If you want to tweak your machine there are different configuration files you can use with your MySQL Server depending on load and what it will be used for. They are located in /usr/local/share/mysql and are called:
my-huge.cnf
my-innodb-heavy-4G.cnf
my-large.cnf
my-medim.cnf
my-small.cnf
We make an example with my-medium.cnf and copy it to /var/db/mysql as my.cnf.
cp /usr/local/share/mysql/my-medim.cnf /var/db/mysql/my.cnf
Read more about these option files at http://dev.mysql.com/doc/refman/5.0/en/option-files.html and maybe you can create your own to suit your needs better than the preconfigured ones.
Good luck with your MySQL Server!

Navigate to /usr/ports/www/apache22 and run make install clean
We probably want Apache to start after a reboot, hence we drop a line to rc.conf.
echo 'apache22_enable="YES"' >> /etc/rc.conf
The file httpd.conf probably needs to be modified slightly.
You find it at /usr/local/etc/apache22/
Modify the following according to your environment:
Listen 123.123.123.123:80
ServerName 123.123.123.123:80
Now you should be able to start Apache with the command /usr/local/sbin/apachectl start.
Or you can run rehash and then apachectl start.
Check out man apachectl for more options and how to use it.
At this point you might get the following error:
[Thu Jan 01 00:00:00 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
To fix this we do the following:
kldload accf_http
And to load it at boot:
echo 'accf_http_load="YES"' >> /boot/loader.conf