Install mysql 5.6 on Ubuntu 18.04 LTS
I'm unable to install mySql 5.6 on my newly installed Ubuntu 18.04. I have tried solution from lots of links ( link1 link2 ... ) but no success at all.
I have 5.7 installed, but due to client's requirement, I need to do it anyhow. There are few changes that make it incompatible with 5.6 without making changes in code in around 5 running projects ( 7 developers involved ) which was started when I was using Ubuntu 17.10 with mysql 5.6.
UPDATE: Ahmed has suggested a manual approach which is a good solution but I wish someone knows to do it Ubuntu's apt way so that more people will be benefited.
I've tried many approaches until I was successful.
The approach that worked
The only approach that worked was downloading the deb-bundble.tar from MySQL website and installing the packages one by one. I followed these steps:
- Go to MySQL 5.6 download page: https://dev.mysql.com/downloads/mysql/5.6.html#downloads
- In the OS options, select "Ubuntu 14.04 64-bit"
- Download the deb-bundle, a file named:
mysql-server_5.6.40-1ubuntu14.04_amd64.deb-bundle.tar
, usually, it's the first option - Untar the bundle somewhere using:
tar -xf mysql-server_5.6.40-1ubuntu14.04_amd64.deb-bundle.tar
- The tar contains multiple
deb
packages, includingmysql-server
,mysql-community-server
, ... etc - Then I tried to install these using:
sudo dpkg -i <package-name>
one-by-one, but I had follow their order according to error messages that fired, e.g.: I first tried:sudo dpkg -i mysql-server_5.6.40-1ubuntu14.04_amd64.deb
, it failed because it requiresmysql-community-server_5.6.40-1ubuntu14.04_amd64.deb
to be installed first and so on. The right order for a few is:mysql-common
,mysql-community-client
,mysql-client
and thenmysql-community-server
. - Some of the package installed successfully, some produced errors, after I have tried
sudo dpkg -i mysql-server_5.6.40-1ubuntu14.04_amd64.deb
for the last time which gave some errors, I desperately tried:sudo apt-get install -f
which grabbed the missing dependencies and voila, MySQL Server 5.6 is successfully installed, up and running
- The tar contains multiple
Approaches that didn't work
Using Trusty Universal Repo
It's worth mentioning that I first tried the same approach that used to work in Ubuntu 16.04, that is, to add the 'trusty universe' repo and try installing mysql-server-5.6, i.e. I followed this:
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
sudo apt-get update
apt-get install mysql-server-5.6
This approach did NOT work. It failed because there's a dependency initscripts
that cannot be installed. It seems that it have been replaced after Ubuntu 16.04. Installing it's replacements: util-util-linux sysvinit-utils
didn't help either.
Using MySQL apt config package
I also tried using MySQL config package (mysql-apt-config_0.7.3-1_all.deb
) I downloaded from this repo: https://repo.mysql.com/ and installed via: sudo dpkg -i mysql-apt-config_0.7.3-1_all.deb
. It didn't recognize Ubuntu 18.04 (bionic) of course, so, I acted as if it's xenial and configured MySQL Server version to 5.6, then I tried to check which MySQL version is now available for installation using: apt-cache policy mysql-server
but that also didn't work, I still have later versions than 5.6.
Final note
Although the last two approaches didn't work, they may have contributed to the success of the first approach by making some packages or configuration available, I honestly don't know.
When I became hopeless that any approach would work, I considered compiling and installing it from source, I started that endeavor (I installed the build essentials and created the user group and the user) and was about to grab the source code when I stumbled upon the deb-bundle that turned out to be fruitful and was the successful approach I described above.
Perhaps a bit offtopic, but my prefered way of solving things like this is to use docker.
you can install docker and docker-compose. Create a docker-compose.yml file, in example /home/whatever/mysql-5.6 that looks like this.
services:
db:
image: mysql:5.6
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
and then do docker-compose up -d
Alternativly you can just install docker-ce, and do a "dryrun" of the image whit the following command to just check it out.
docker run -it mysql:5.6 /bin/bash
Full explanation of the mysql Dockerfiles, here. https://hub.docker.com/_/mysql/
MariaDB is a fully compatible drop-in replacement for MySQL, and is available in the default Ubuntu repositories. It can be installed with:
sudo apt update
sudo apt install mariadb-server-10.0 mariadb-client-10.0
The setup should detect all existing MySQL databases and import them, but just in case, read this answer, and have a backup ready.
Notes about MariaDB
While the question is about MySQL
, MariaDB
is an enhanced, drop-in replacement for MySQL
and is compatible with all* applications that use MySQL. It listens on the same ports and all the commands are the same(i.e. mysql
,mysqldump
, etc.).
*Ok, you can probably find some really old applications that won't work with MariaDB, but the chances of that are really, really small.
You can download & install Mysql 5.6 debian packages manually from Mysql apt repository.
I know this answer is a little bit late. but, i had to mention that current version of MySQL APT Repository (mysql-apt-config_0.8.12-1_all.deb) worked fine with me on Ubuntu 18.04.
here is how to use it.