Tuesday 30 April 2019

Install MySQL Version under Ubuntu Server 18

Install old MySQL Version 5.0.27

Installing old MySQL Versions on newer systems (in my case Ubuntu Server 18.04), can result in many compiling errors. One of them was the following error:

mysqld.cc:5997:1: error: narrowing conversion of ‘18446744073709551615’ from ‘ulong {aka long unsigned int}’ to ‘longlong {aka long int}’ inside { } [-Wnarrowing]}

After 2 days of headaches, I got it finally fixed and wanted to share the solution with you.

Pre setup


First, we need to create the mysql users and install the required packages

$ groupadd mysql
$ useradd -m -d /usr/local/mysql -s /bin/false -g mysql mysql
$ apt install build-essential libncurses5-dev

Download


Download and unpack the MySQL Tarball to your Server
$ cd /usr/local/src
$ wget https://downloads.mysql.com/archives/get/file/mysql-5.0.27.tar.gz
$ tar xvzf mysql-5.0.27.tar.gz
$  cd mysql-5.0.27/

Configure


Now we configure the sources, give them our prefix path and set the C++ compiler language standard to gnu++98 (Standard Language from 1998). Without setting the language standard, you will get several errors while compiling.

$ ./configure --prefix=/usr/local/mysql --with-mysqld-user=mysql CXXFLAGS="-std=gnu++98"
$ make
$ make install

Start


We now have to install the initial db, copy the start script and the config and change the directory rights, so we can start our MySQL Server

$ /usr/local/bin/mysql_install_db
$ cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
$ cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql/etc/my.cnf
$ chown mysql:mysql /usr/local/mysql
$ vi /etc/init.d/mysql

Change the first line of /etc/init.d/mysql from #!/bin/sh to #!/bin/bash

$ /etc/init.d/mysql start

3 comments:

  1. I'm not able to do this: /usr/local/bin/mysql_install_db
    Can you help me?

    ReplyDelete
  2. Thanks bro, you saved my life! :)

    ReplyDelete
  3. thank you very much!!! CXXFLAGS="-std=gnu++98" is a very important tip!!

    ReplyDelete