In this tutorial, we'll learn how to install Percona Server for MySQL Ubuntu 24.04. An optimized MySQL fork with better performance and scalability.
Introduction
Percona Server for MySQL is an enhanced and drop-in replacement for MySQL. Percona has focused on optimizing MySQL’s performance and scalability, making it a robust choice for high-traffic environments. In addition, it includes advanced troubleshooting, monitoring, and performance instrumentation features.
Because Percona Server for MySQL is fully compatible with MySQL, migrating or switching between them is relatively straightforward. Below, you’ll learn how to install Percona Server for MySQL on Ubuntu 24.04 step by step. By the end, you’ll have a working installation that you can begin using for your databases.
Prerequisites
- A Ubuntu 24.04 installed dedicated server or KVM VPS.
- A root user or normal user with administrative privileges.
Install Percona Server for MySQL Ubuntu
Step 1: Update Your Server’s Package Index
Open Terminal or SSH: Log in to your Ubuntu 24.04 system. If you’re using a remote server, connect via SSH.
Update the package list: Keep your system’s package index up to date before installing anything new. Run:
sudo apt update
- This command fetches the latest index of available packages and their versions from the configured repositories.
- Keeping your package index current ensures you’re installing the newest versions and reduces potential conflicts.
(Optional) Upgrade the system: If you’d like to ensure your entire system is up to date, run:
sudo apt upgrade
This upgrades all currently installed packages to their newest versions. It’s usually a good practice to run this periodically. However, it’s optional if you only want to install Percona Server for MySQL.
Step 2: Add the Percona Repository
Percona maintains its own repositories for various distributions, including Ubuntu. Using this official repository ensures you install the latest stable version of Percona Server for MySQL along with any minor updates or patches.
Fetch Percona’s GPG key:
wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb
This file contains the repository information needed for apt (the package manager on Ubuntu). By downloading it, you’re preparing your system to trust packages from Percona.
Enable the Percona Server 8.0 repository
percona-release setup pdps8.0
Install the downloaded package:
sudo dpkg -i percona-release_latest.generic_all.deb
This command installs the .deb file you just downloaded, effectively registering Percona’s repository and GPG key with your system.
Update your package index again:
sudo apt update
Now that the Percona repository is registered, Ubuntu needs to refresh its package list again to acknowledge the newly added source.
Step 3: Install Percona Server for MySQL
Install Percona Server:
sudo apt install percona-server-server
- This command will fetch and install the Percona Server for MySQL package from the newly added Percona repository.
- If apt asks you to confirm the download and installation, type Y (or y) and press Enter.
Confirm successful installation:
Watch the console output for any error messages. If everything proceeds smoothly, it will install and automatically start the Percona MySQL service on your system.
Check service status:
sudo systemctl status mysql
Percona Server for MySQL typically uses the mysql systemd service name. If it’s active (running), then your installation was successful.
Step 4: Secure the MySQL Installation
Percona Server for MySQL, like standard MySQL, includes a script called mysql_secure_installation
that helps you quickly improve the security of your new database server.
Run the secure installation script:
sudo mysql_secure_installation
Follow the prompts:
Set root password: You’ll be asked if you want to set the MySQL root password. Choose “Yes” and enter a strong password. This password is used when you connect to MySQL as the root user for administrative tasks.
- Remove anonymous users: Generally, you should remove anonymous accounts for security.
- Disable remote root login: Unless you need to manage the server remotely as root, it’s safer to block remote root logins.
- Remove test database: The test database can be used to store data by anyone, so it’s safer to remove it in a production environment.
- Reload privileges: Finally, the script will ask to reload privilege tables. You should say “Yes” to ensure your changes take effect immediately.
This script automates best practices for MySQL security on your Percona Server and helps protect your data from unauthorized access.
Step 5: Test and Verify the Installation
Log in to MySQL:
mysql -u root -p
- Enter the root password you defined during the Percona installation script.
- If you reach the MySQL shell (it looks like mysql>), the server is running correctly.
Show existing databases:
SHOW DATABASES;
You should see default MySQL system databases such as information_schema, performance_schema, etc.
Type exit; or \q to return to the shell.
(Optional) Create a test database:
CREATE DATABASE test_db;
This command creates a new database called test_db. It’s a simple way to verify that your server is fully functional and that you can create and manage new databases.
Step 6: Basic Configuration Tweaks (Optional)
Depending on your workload, you may need to tweak Percona Server’s configuration files. These are typically located in the /etc/mysql/ directory on Ubuntu.
Locate the configuration file:
The main configuration file (for MySQL 8.0 variants including Percona Server) is often named my.cnf or found in /etc/mysql/percona-server.conf.d/.
Common settings to adjust:
- bind-address: The IP address on which MySQL listens for connections. If you need external access, you might change this from 127.0.0.1 to your server’s IP. But always ensure you have proper firewalls and user permissions set up.
- max_connections: The number of simultaneous connections MySQL can handle. You can increase this if expecting many client connections.
- query_cache_size or other performance-related variables. Percona may have different defaults or recommended values compared to standard MySQL, especially for high-performance environments.
Restart to apply changes:
sudo systemctl restart mysql
Any modifications made to the configuration files require a restart for the changes to take effect.
Step 7: Ongoing Maintenance and Updates
Monitor and update:
Use standard Ubuntu commands to update the server:
sudo apt update
sudo apt upgrade
This will keep Percona Server for MySQL up-to-date with the latest security patches and improvements as provided by the Percona repository.
Logs and troubleshooting:
Monitor the MySQL error log located by default in /var/log/mysql/. If you run into performance or stability issues, you’ll find valuable debugging information there.
Utilize Percona Tools:
Percona provides a set of command-line utilities like Percona Toolkit (e.g., pt-query-digest, pt-online-schema-change) to help you optimize and maintain your databases. Consider installing them if you want more advanced control and performance tuning.
Conclusion
By installing Percona Server for MySQL on Ubuntu 24.04, you’re setting up a robust, high-performance database solution. This tutorial showed you how to:
- Update your Ubuntu system
- Add and use the official Percona repository
- Install and verify Percona Server for MySQL
- Secure the installation using mysql_secure_installation
- Perform basic configuration tweaks
From here, you can explore more advanced features offered by Percona. Whether you’re hosting a small application or a large-scale enterprise service, Percona Server for MySQL can provide the performance and reliability you need. Don’t forget to check the official Percona documentation for more in-depth performance tuning and advanced replication features once you’re comfortable with the basics.