One of the things that I've been wanting to do is build MySQL. I checked out this blog from Neel and the instructions posted on the MySQL site and it looked fairly straightforward. After going through the steps, I can say that it proved to be quite simple. Note that I built the latest rc candidate of MySQL on OpenSolaris using Sun's compilers. Here are the steps for people who are interested.
- Install OpenSolaris. I already have OpenSolaris 2008.05 running within VirtualBox on my laptop. If you need the ISO image, it can be downloaded from here.
- Install Sun compilers by issuing the following command: pfexec pkg install ss-dev. The tools are installed in /opt/SunStudioExpress.
- Prepare the user environment for MySQL by issuing the following commands:
- groupadd mysql
- useradd -g mysql mysql
- Become the mysql user with su mysql.
- Download the latest MySQL source from dev.mysql.com. I downloaded the compressed GNU TAR archive (tar.gz) version 5.1.29-rc from here.
- Extract the MySQL source code from the archive with the commands below. The source code will be extracted to mysql-5.1.29-rc.
- gunzip mysql-5.1.29-rc.tar.gz
- tar xvf mysql-5.1.29-rc.tar
- Set the following environment variables:
- export CC=/opt/SunStudioExpress/bin/cc
- export CXX=/opt/SunStudioExpress/bin/CC
- export CFLAGS="-xO3" #Change this to have your compiler variables
- export CXXFLAGS="-xO3"
- export PATH=$CC:$CXX:/usr/sfw/bin:/usr/ccs/bin:$PATH
- Create a sym link from gmake to make with cd /usr/sfw/bin ; ln -s gmake make
- cd to the source code directiory. In my case mysql-5.1.29-rc.
- Execute the following command at the prompt: ./configure --prefix=/usr/local/mysql
- The configure command allows you to control the configuration of the MySQL source distribution. A full listing of the options to configure can be found here. Prefix simply installs architecture-independent files in the location specified by prefix (everything is installed under
/usr/local/mysqlrather than the default of/usr/local). - Execute the following command at the prompt: make
- Execute the following command at the prompt: make install
At this point, under /usr/local/mysql/bin, you will see the mysql_install_db script, which will allow you to install MySQL. After that, you can run mysqld_safe to start mysql.
Related post: http://blogs.sun.com/amitsaha/entry/mysql_6_0_alpha_on2
Posted by Amit on November 10, 2008 at 09:00 PM PST #