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.
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).
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
.
- 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 usingmysql:5
you have to install the 5.7 client.