Skip to content

Instantly share code, notes, and snippets.

@bhubr
Last active March 17, 2020 10:16
Show Gist options
  • Save bhubr/92ac7350a3393600318b8a5c613e5914 to your computer and use it in GitHub Desktop.
Save bhubr/92ac7350a3393600318b8a5c613e5914 to your computer and use it in GitHub Desktop.
MySQL client installation on Ubuntu

MySQL client installation on Ubuntu

Since MySQL has been acquired by Oracle, who made licensing changes to the product, major Linux distributions have started adopting MariaDB instead, and don't ship MySQL by default.

Follow these steps to install Oracle MySQL on your Ubuntu machine.

Add the MySQL APT Repository

apt is Ubuntu's software installer. It works with "repositories" where software packages are stored. First you have to tell it where MySQL's repositories are.

You first have to download mysql-apt-config (you may find a more recent version on the MySQL APT Repository download page).

wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb

Then install it using dpkg (the low-level package manager on which apt relies):

sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb

At some point (now or a bit later in the install process) you'll land in a "text-mode menu", titled "Configuring mysql-apt-config". The first entry is especially relevant, since it allows you to choose between several MySQL versions. You should choose mysql-5.7 (default version used at Wild Code School), unless your instructor tells you otherwise. For use with Docker, it also depends on the MySQL Server image you're going to use (see the end of this document).

Update the list of known packages

Then run the following command to make apt fetch the list of available packages, from the MySQL repos. Beware, this may fail (informations below on how to solve the issue).

sudo apt-get update

In case of failure, follow the instructions in this article.

You should now be able to re-run sudo apt-get update.

Install what you need

  • If you need only the client: sudo apt-get install mysql-client
  • You might be asked which version you want to install (5.7 or 8.0).
  • If you also install the server, make sure both clients and server have the same version.
  • If you're using Docker, the version you install depends on the MySQL Docker image you're using. If you're using mysql it defaults to the latest version (8), if you're using mysql:5 you have to install the 5.7 client.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment