Home » Guides » 4 Methods to Install MySQL on Linux, Debian, Ubuntu, CentOS, Fedora, RHEL, Arch, OpenSUSE, Mint, Manjaro, Kali, etc.

4 Methods to Install MySQL on Linux, Debian, Ubuntu, CentOS, Fedora, RHEL, Arch, OpenSUSE, Mint, Manjaro, Kali, etc.

A DBMS software is crucial to those looking to manage a database. As such, MySQL is available across multiple platforms, including Linux. Although the app comes pre-installed with most distros, it is always crucial to know how to install MySQL, as some versions are simply irreplaceable from a certain point of view.

Hence, the following article aims to guide users throughout the MySQL installation process on any Linux distro.

What is MySQL?

MySQL is a computer application that stands for My – taken from the co-founder’s daughter’s name, and SQL – Structured Query Language. It is a relational DBMS that is very popular due to its applicability and open-source nature.

MySQL Logo

The software is developed, distributed, and maintained by the Oracle Corporation, a giant in IT software. Talking about MySQL, one has to first understand that any database is a structured collection of data. This data can range from anything simple, such as your grocery list to a nation’s budget.

However, we all know that such a set of data is dynamic in nature. Thus, it is in constant need of an upgrade to keep up with the times. That’s where MySQL comes into play.

Anytime a user wants to add, access, or preprocess the data stored in a database, he needs a corresponding DBMS software. And MySQL is one such software. Furthermore, we all know how central computers are in data applications, viz a viz so is the DBMS as a standalone or as a part of another application.

What sets MySQL apart from other DBMSs is the fact that its databases are relational. A relational database stores data in specific tables, rather than piling them up together in a giant mess.

To add to the injury, these specific and structured tables can then be organized and processed into separate files. And these files are not only optimized for speed but also controllable within the rules framework set up by the user.


Before we begin with our demonstration, the user has to ensure the following:

  • A working internet connection
  • Access to the root folder on the device
  • A Linux distro

Installing MySQL on Linux

Now, let us proceed with our MySQL installation on Linux using the various methods mentioned below:

Method 1. Using Generic Binaries

Oracle already offers a set of binary MySQL distributions, including generic binaries. These are in the form of .tar.xz files. Thus, the user is required to decompress the file and install MySQL on the system. The relevant steps are:

Step 1. Power up your device and run the command terminal by pressing the Ctrl + Alt + T buttons.

Step 2. Then, create a MySQL User and Group. For this, the user would need root access or use the SUDO command :

sudo groupadd mysql
sudo useradd-r-g mysql-s/bin/false mysql

Step 3. Now unpack the distribution obtained. For this, users first need to pick a directory and then change the default location. The commands are:

sudo cd/usr/local
sudo tar xvf /path/to/mysql-VERSION-OS.tar.xz

Step 4. Now, create a symbolic link to the installation directory.

ln -s full-path-to-mysql-VERSION-OS mysql

Step 5. Voilàit’s, it’s done.

Method 2. Using MySQL repositories

The next method utilizes the native Linux repositories as Oracle offers MySQL through them. Let’s see how to install the software using these repositories.

Using the YUM Repository

Step 1. Start by loading the command terminal.

Step 2. Then go to the MySQL download page: https://dev.mysql.com/downloads/repo/yum/

Step 3. Now download the RPM package:

sudo yum install platform-and-version-specific-package-name.rpm

Step 4. Before proceeding users should double-check if the repository has been added successfully:

sudo yum repolist enabled | grep "mysql.*-community.*"

Step 5. After that, install MySQL using the YUM command:

sudo yum install mysql-community-server

Step 6. And that’s it, users can now use MySQL.

Using the APT Repository

The steps are mostly similar, just the commands are changed:

Step 1. First, go to the MySQL APT repository download page at: https://dev.mysql.com/downloads/repo/apt/.

Step 2. Now, download the DEB package for your distro.

Step 3. Then, install the package using the DPKG command:

sudo dpkg -i /PATH/version-specific-package-name.deb

Step 4. After that, update the APT repository.

sudo apt-get update

Step 5. Finally, install the app using the APT-GET command:

sudo apt-get install mysql-server

Using the SLES Repository

Now, the steps regarding SLES repository:

Step 1. First, go to the MySQL SLES repository download pagehttps://dev.mysql.com/downloads/repo/suse/

Step 2. Now download the SUSE package.

Step 3. After that install the package using the RPM command:

sudo rpm -Uvh package-name.rpm

Step 4. Now, users should import the MySQL GnuPG Key using the following command:

sudo rpm --import /etc/RPM-GPG-KEY-mysql-2022

Step 5. And finally, install MySQL using the ZYPPER command:

sudo zypper install mysql-community-server

Method 3. Installing directly with Oracle Packages

Users can directly install MySQL using the distro packages issued by Oracle. Here’s how:

Using RPM Packages

Users are recommended to install MySQL on RPM based Linux distros using the relevant package from Oracle. The steps are:

Step 1. Download the package from the Community Server page in the MySQL Developer Zone.

Step 2. Use the following command for installation:

sudo yum install mysql-community-{client,client-plugins,common,libs}-*

Using Debian Packages

Step 1. Go to the MySQL Developer Zone and download the Debian package.

Step 2. Now unpack the package using the following command:

tar -xvf mysql-server_MVER-DVER_CPU.deb-bundle.tar

Step 3. After that, install the libaio library.

sudo apt-get install libaio1

Step 4. Configure your package for installation:

sudo dpkg-preconfigure mysql-community-server_*.deb

Step 5. Then finally, install MySQL.

sudo dpkg -i mysql-{common,community-client-plugins,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb

Method 4. Using Native Software Repositories

Most Linux distros come pre-installed with a version of MySQL. The relevant client tool and other components are available in the native repositories. And these cab be installed using the standard package management system.

For Red Hat Linux, Fedora, CentOS

Use the installation command:

yum install mysql

For Debian, Ubuntu, Kubuntu

The command is:

apt-get install mysql

FAQ: Installing MySQL on Various Linux Distributions

Here are some FAQs that might help you while installing or trying to install MySQL on your computer. If you have any further questions, contact us. We will do our best to help you.

1. What are the four methods to install MySQL on Linux?

The four common methods to install MySQL on various Linux distributions are:

  • Using the default package manager (apt, yum, dnf, zypper, pacman, etc.) specific to each distribution.
  • Downloading and installing from the official MySQL repositories.
  • Installing using Docker containers.
  • Compiling MySQL from source.

2. Can I use apt to install MySQL on all Linux distributions?

No, the apt command is specific to Debian-based distributions like Ubuntu, Debian, Mint, and Kali. For RPM-based distributions like CentOS, Fedora, and RHEL, you would use yum or dnf. Arch and Manjaro typically use pacman, while openSUSE uses zypper.

3. Is there a universal method for installing MySQL across all Linux distributions?

While there isn’t a single universal command, using Docker can be considered a distribution-agnostic method. By running MySQL inside a Docker container, you can bypass the native package management system, which varies between distributions.

4. How do I ensure that MySQL is properly installed and secured after installation?

After installation, it’s recommended to run the mysql_secure_installation script. This script helps improve MySQL security by setting the root password, removing anonymous user accounts, disabling remote root logins, and removing test databases.

5. What should I do if my Linux distribution doesn’t have MySQL in its default repository?

If MySQL is not available in your distribution’s default repository, you can add the official MySQL repository to your system or download the packages directly from the MySQL website. Instructions for setting up the repository are usually provided on the MySQL website.

6. Are there any differences in the installation process between community and enterprise editions of MySQL?

Yes, there are differences primarily in terms of package availability and support. The Enterprise edition might require access credentials for downloading, as it includes additional features and support services. The Community edition is freely available through standard repositories or can be downloaded from the MySQL website.

Gilbert John Avatar