MySQL is one of the most widely used open-source relational database management systems, running innumerable websites and applications. Installing MySQL using the official MySQL APT repository guarantees that you have access to the latest stable version, along with automatic updates and enhanced security.
In this guide, we’ll walk you through how to install MySQL on a Linux server (Ubuntu or Debian-based systems) using the MySQL APT repository.
Table of Contents:
What is the MySQL APT Repository?
The MySQL APT repository is an official package source maintained by Oracle. It allows Linux users to:
- Install the latest stable version of MySQL directly from Oracle’s repository.
- Automatically receive updates through the Linux package manager.
- Access related tools such as MySQL Workbench, MySQL Router, and Connector packages.
This method guarantees that your hosting server remains up-to-date and secure.
Step-by-Step Installation Process
Step 1: Add the MySQL APT Repository
- Visit the official MySQL APT repository download page.
- Download the repository configuration package:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb
- Install the repository package:
sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb
- During installation, a configuration window will appear.
- Choose the MySQL Server version you want to install (e.g., MySQL 8.0).
- Confirm and exit the configuration window.
Step 2: Update the Package List
To update the package list, execute the following command:
sudo apt update
This confirms your system identifies the newly added MySQL APT repository.
Step 3: Install MySQL Server
- Using the following command, install the MySQL server package:
sudo apt install mysql-server
- Once installation begins, you will be encouraged to:
- Set a root password for MySQL.
- Choose an authentication method (the default is recommended for most setups).
Step 4: Secure the MySQL Installation
- After installation, run the built-in security script to improve your server’s safety:
sudo mysql_secure_installation
- Follow the on-screen prompts to:
- Remove anonymous users.
- Disallow remote root login (recommended).
- Remove the test database.
- Reload privilege tables.
Step 5: Verify the Installation
- To confirm that MySQL is running properly, run the following command:
sudo systemctl status mysql
- You can also log in to the MySQL shell, using:
sudo mysql -u root -p
Enter the password you created earlier to access the MySQL prompt.
Best Practices for Hosting Servers
- Enable automatic updates to receive the latest MySQL patches.
- Regularly back up databases using tools like ‘mysqldump’ or remote backup services.
- Restrict access to the MySQL port (3306) using a firewall or security group.
- Monitor performance using ‘mysqladmin’ or a hosting control panel like ‘cPanel or Plesk’.
Conclusion
From the above-outlined article, it is clear that installing MySQL via the MySQL APT repository is a reliable and secure way to manage database versions on Linux hosting servers. This method ensures compatibility, timely updates, and smooth integration with your web applications.
Whether you’re managing a shared, VPS, or dedicated server, using the APT repository for MySQL installation is a best practice for developers and hosting professionals.
If you require additional assistance, please contact our support staff.
A Linux VPS Hosting solution provides full root access, dedicated resources and the flexibility needed to deploy, manage and optimise MySQL database environments.
Having issues running MySQL commands? Learn How to Fix “MySQL Command Not Found” Error