Saturday, October 01, 2005

Installing MySQL on FreeBSD

I'm installing MySQL in a fresh FreeBSD jail and thought it'd be a good idea to document the quick, easy process, so the next time someone asks me how to do this, I can just point them to this.

Update your Ports
First, cvsup your ports collection so you have the most recent versions available.

Choose a Version
This isn't very clear or simple. There are four different MySQL versions in FreeBSD ports - 3.23, 4.0, 4.1, and 5.0. Unless your intended application only works with MySQL 3.x, I wouldn't recommend using that version. MySQL 5 is the current development version, so I wouldn't recommend it for production use either. MySQL 4.1 is the latest "production release" as of this writing, so generally this is what you will want to use.

The installation is almost as straight forward as usual. There are some make options that may be of interest.

You may use the following build options:

WITH_CHARSET=charset Define the primary built-in charset (latin1).

WITH_XCHARSET=list Define other built-in charsets (may be 'all').

WITH_COLLATION=collate Define default collation (latin1_swedish_ci).

WITH_OPENSSL=yes Enable secure connections.

WITH_LINUXTHREADS=yes Use the linuxthreads pthread library.

WITH_PROC_SCOPE_PTH=yes Use process scope threads
(try it if you use libpthread).

BUILD_OPTIMIZED=yes Enable compiler optimizations
(use it if you need speed).

BUILD_STATIC=yes Build a static version of mysqld.
(use it if you need even more speed).

WITHOUT_INNODB=yes Disable support for InnoDB table handler.

WITH_NDB=yes Enable support for NDB Cluster.

For the most common uses you can get by without any options. I typically use BUILD_OPTIMIZED and BUILD_STATIC.

cd /usr/ports/databases/mysql41-server
make BUILD_OPTIMIZED=yes BUILD_STATIC=yes install clean

MySQL will now install.

Configure to Start on Boot
A startup script is installed in the usual location, /usr/local/etc/rc.d/. Before this startup script will function, you need to open your /etc/rc.conf and add the line mysql_enable="YES".

Start MySQL
MySQL is now configured to start at boot, but you probably don't want to reboot just to get it to start. Just run the following.

/usr/local/etc/rc.d/ start

Now MySQL is running and ready for use.


Anonymous Anonymous said...

yeh where is the info on how to enable ndb, and how to configure ndb.

11:22 AM  
Blogger Jim said...

I followed your instructions for installing mysql and when I ran the command to start it, I got a No Such File or Directory Error

4:31 PM  
Blogger Jim said...

I followed your instructions for installing mysql and when I ran the command to start it, I got a "No Such File or Directory Error"

4:32 PM  
Anonymous Armando Padilla said...

Hi, just read your article. Thanks for documenting this.

Jim: you get "No Such File or Directory Error" because the command "mysql" is not in your global path settings.

Try running. /usr/local/bin/mysql if you cant run it from there try to look up any mysql files using find. Example: find / -name mysql, the results of that command should give you all the paths to mysql files

Armando Padilla

12:14 PM  
Blogger John said...

"Before this startup script will function, you need add the line.."

Thanks, that's exactly what I was missing. I wish mysql gave an error to alert you about that.

3:26 PM  
Anonymous Tom said...

Jim: Type in rehash
it rediscovers your path

8:54 AM  

Post a Comment

<< Home