Installing Mysql 5.1 on FreeBSD 7.0

Well we all love Mysql and a lot of times it is the first things we install on a server. I recently installed it on my FreeBSD 7.0 server and it went pretty smooth. You can install mysql from the FreeBSD Ports Collection.

BSD and Mysql

cd /usr/ports/databases/mysql51-server
make install clean

Then you will have to wait until the package builds itself from source. This may take some time so feel free to browse around the rest of the blog or grab a bite to eat. This link will take you to a random article.

Once that is done you will want to use mysql’s install script to get you up and running:

/usr/local/bin/mysql_install_db

Make the mysql directory owned by the user, ‘mysql‘.

chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/

Run mysql as the ‘mysql‘ user.

/usr/local/bin/mysqld_safe –user=mysql

Then you will want to set the Mysql root password:

/usr/local/bin/mysqladmin -u root password YoUrPaSSwoRd

Start Mysql on Boot

 
You will probably want Mysql to start on boot. To enable Mysql on boot you will need to add a line to your rc.conf file. I used my favorite text editor vim to edit it.

vim /etc/rc.conf

Then add the following lines near the bottom:

# Enable Mysql
mysql_enable="YES"

Thats it! You should have a working installation of mysql and have it configured to load up on boot.


Was this information useful?


7 Responses to "Installing Mysql 5.1 on FreeBSD 7.0"
  1. Installing Apache on FreeBSD 7.0 on August 14th, 2008

    [...] that you have MySQL installed you might want to install the famous Apache web browser on your FreeBSD system. This post will be a [...]

  2. Robert Waksmundzki on November 9th, 2008

    Or you could use :

    cd /usr/ports/databases/mysql51-server
    make install clean
    echo “mysql_enable=”YES”" >> /etc.rc.conf
    /usr/local/etc/rc.d/mysql-server start

    Since FreeBSD detects a fresh install and initializes the data dir for you.

  3. Mark Sanborn on November 9th, 2008

    Robert,

    Good call.

  4. R. Owens on December 29th, 2008

    Thanks for clear description. If I am updating to a new version of MySQL, instead of installing from scratch, how would the above be modified in order to preserve existing database contents. Thanks

  5. Mark Sanborn on December 29th, 2008

    The standard upgrade FreeBSD method should work. I would back up your databases before the upgrade however and always have regular mysqldumps.

  6. [...] install mysql on http://www.marksanborn.net 2. install apache on http://www.marksanborn.net 3. faruqafif.student.fkip.uns.ac.id 4. [...]

  7. Joe on October 31st, 2009

    Good tutorial. Quick, clean, simple, easy.

    It has been a while since I have done admin work on a FreeBSD server and this got me through the MySQL setup quick and error-free.

    God Bless.