A binary tarball installation gives you full control over the MySQL directory and version. Unlike a distribution package, it does not automatically create the system user, configure permissions, install a service, or apply security updates.
1. Download and verify the package
Choose the archive that matches your CPU architecture and glibc version from the official MySQL downloads page. The example filename below is illustrative:
1 | wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.39-linux-glibc2.28-x86_64.tar.xz |
Compare the checksum with the value published by MySQL. Install required runtime libraries through your operating system package manager.
2. Create a service account and directories
1 | sudo groupadd --system mysql |
Keep program files owned by root and writable data directories owned by mysql.
3. Configure MySQL
Create /etc/my.cnf:
1 | [mysqld] |
Binding to localhost is a safe default. If remote clients are required, use a private interface, firewall rules, TLS, and least-privilege database accounts.
4. Initialize the data directory
1 | sudo -u mysql /opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize |
Save the temporary password securely. Do not use --initialize-insecure on a production server.
5. Create a systemd unit
Create /etc/systemd/system/mysql.service:
1 | [Unit] |
Load and start it:
1 | sudo systemctl daemon-reload |
6. Finish hardening
Connect with the temporary password and set a strong replacement, then run:
1 | /opt/mysql/bin/mysql_secure_installation |
Remove anonymous accounts and test databases, review root access, configure backups, and monitor disk capacity and replication if used. Add /opt/mysql/bin to a system-wide PATH only after confirming it cannot be modified by untrusted users.
Upgrades and rollback
Never replace the symlink and start a new MySQL binary without reading that release’s upgrade procedure. Take a tested backup, stop cleanly, preserve the old binaries, and rehearse the change on a copy of the data. Package-managed installations are usually easier to patch; use tarballs only when their control is worth the additional maintenance.
