Install MySQL Server 5.0 and 5.1 from source code

Have you ever tried to download and install MySQL server 5.0 or 5.1 from source code? If you have not but want to, here are the easy steps to do so on a Debian/Ubuntu Linux machine. These instructions should work on other Linux distributions e.g. SUSE, RedHat, CentOS etc. Firstly, you will need to install libncurses. Luckily, I have already written about how to install libncurses here. Next, you need to decide what MySQL version you wish to install.

In this tutorial, I have only explained the installation instructions for MySQL 5.0 and 5.1. The specific version of MySQL database server that I chose are 5.0.91 and 5.1.51. These instructions were tested on Debian Lenny. Please make sure you check the downloaded file's integrity before unzipping it (click here for more info on this). '#' (w/o quotes) in front of the commands below means you have to run the command as root user (or use sudo ).

You have to download MySQL source code tarred and gzipped files from MySQL's website first. For MySQL version 5.0 and lower, you have to go to the Archives page on MySQL's website. You can download the files for mysql 5.0.91 from http://downloads.mysql.com/archives.php?p=mysql-5.0&v=5.0.91. You can change the installation directory in ./configure commands below by changing the value assigned to prefix option.

How to install MySQL 5.5 from source code on Linux:

This topic was pretty long, so I wrote a separate tutorial "Download, configure, compile, and install MySQL 5.5.8 from source code on Linux".

How to download and configure MySQL 5.1 for installation:

$ wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz/from/http://mysql.he.net/

$ tar xzf mysql-5.1.51.tar.gz

$ cd mysql-5.1.51

$ ./configure --enable-profiling --prefix=/opt/mysql-5.1.51/ --enable-local-infile \
 --with-mysqld-user=mysql  --with-big-tables \
 --with-plugins=partition,blackhole,federated,heap,innodb_plugin --without-docs \
 --with-named-curses-libs=/opt/ncurses/lib/libncurses.a #replace the ncurses location a/c to your system

How to download and configure MySQL 5.0 for installation:

$ wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.91.tar.gz

$ tar xzf mysql-5.0.91.tar.gz

$ cd mysql-5.0.91

$ ./configure --enable-community-features --prefix=/opt/mysql-5.0.91/ --enable-local-infile \
--with-mysqld-user=mysql --with-big-tables --with-plugins=partition,blackhole,federated,heap,innodb_plugin \
--without-docs \
--with-named-curses-libs=/opt/ncurses/lib/libncurses.a #replace the ncurses location a/c to your system

Install MySQL 5.0 and 5.1:

Now, after configuring the MySQL server you just have to compile and install it on your machine. Note: Compilation might take a while to finish

$ make
# make install

In order to make sure the installed software is there, list the contents of /opt directory by running the following command.

$ ls -lah /opt

Now, that you have successfully installed MySQL server on your Linux machine, its time to initialize the databases. Click here for more info on how to do that.

Did this tutorial help a little? How about buy me a cup of coffee?

Buy me a coffee at ko-fi.com

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.

IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.

Comments (write a comment):

can i compile and install as non-root user? Posted by: anh on Mar 19, 2011

i get this error :
g++: /opt/ncurses/lib/libncurses.a: No such file or directory

when running make command..
Please help. Posted by: Arihant k on Apr 03, 2011

The ncurses problem was resolved .

now i get following error after make install :

make[3]: *** [install-benchSCRIPTS] Error 1
make[3]: Leaving directory `/opt/mysql-5.0.91/sql-bench'
make[2]: *** [install-am] Error 2
make[2]: Leaving directory `/opt/mysql-5.0.91/sql-bench'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/opt/mysql-5.0.91'
make: *** [install] Error 2 Posted by: Arihant k on Apr 03, 2011

@anh: yes, you can compile and install using non-root user (depending upon where you want to store the installed files) Posted by: Shahryar G on Apr 06, 2011

@Arihant: Can you also post the configure command that you used?

thanks. Posted by: Shahryar G on Apr 06, 2011

I have to use open source code for editing purpose in windows 7.please tell me the steps and i have already installed the mysql-essential-5.1.31-win32 version. so these both can work independently or not.
Thanks.. Posted by: Amit B on Jan 10, 2012

if you want to run two instances of MySQL on the same machine then you can run them on different ports. You can specify ports using the port option in mysql configuration file or command line.

You can download MySQL source code from MySQL's website.

Thanks. Posted by: shahryar g on Feb 01, 2012

"i get this error :
g++: /opt/ncurses/lib/libncurses.a: No such file or directory

when running make command..
Please help."
You need to install libncurses-dev Posted by: Alexandr on Nov 04, 2014

When I run the 'make' command, I get the following error.

/usr/bin/ld: cannot find /opt/ncurses/lib/libncurses.a File format not recognized
collect2: error: Id returned 1 exit status Posted by: Manny on Jan 19, 2015

i get this error :
g++: /opt/ncurses/lib/libncurses.a: No such file or directory

when running make command..
Please help. Posted by: Gyasuddin on Sep 30, 2016

@gyasuddin: plz make sure you're pointing to the right directory.

It looks like ncurses is installed in a different directory Posted by: sid on Oct 07, 2016

leave a comment on tutorial leave a comment