Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

On an Ubuntu VPS, the reliable MySQL workflow is straightforward: install the distribution package, verify and secure the service, create a database-specific application account, keep MySQL off the public internet unless remote access is truly required, and operate a backup-and-restore process you have actually tested.

This guide covers those tasks in the order you will need them, including commands, privilege decisions, firewall boundaries, backup choices, recovery checks, and the maintenance habits that prevent a small configuration change from becoming an outage.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you are managing when you run MySQL on a VPS

MySQL is a database server process running inside your virtual private server. It stores schemas (databases), tables, indexes, users, and configuration on the VPS filesystem. Your web application normally connects over the local socket or loopback interface, so the database does not need to be reachable from the public internet.

There are two different kinds of “root” to keep straight:

#1 Best Overall
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
  • Linux root is the operating-system administrator account. sudo temporarily gives a permitted command that level of access.
  • MySQL root is a database account. MySQL identifies an account by both username and client host, so 'root'@'localhost' and 'root'@'some-host' are distinct account identities.

Use the Linux administrator account to install packages and edit service configuration. Use MySQL accounts and SQL privileges to control what applications and operators can do inside the server.

Install MySQL on Ubuntu and verify the service

Install from the operating-system package

For an Ubuntu VPS, install the packaged server rather than downloading an unrelated binary:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install mysql-server

The package normally starts MySQL after installation. Confirm that it is running:

sudo systemctl status mysql
# or
sudo service mysql status

A running service should show an active state. If it failed, read the service journal before changing settings:

sudo journalctl -u mysql

Keep the output, including the first error in the sequence. Later messages often describe consequences rather than the original cause.

Complete the initial security workflow

MySQL’s post-installation workflow includes starting the server, testing access, securing the initial account, and arranging automatic startup. On Ubuntu package installations, run the interactive hardening utility when it is available:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
sudo mysql_secure_installation

Read each prompt instead of accepting a remembered answer from another server. The appropriate choices depend on whether you need legacy accounts, anonymous access, test objects, or local administrative access. Verify that you can still perform the administrative action you need before ending the session.

Do not place a password directly in a shell command line. Shell history and process listings can expose it. Prefer the client’s password prompt, a protected option file, or MySQL’s login-path mechanism with filesystem permissions that prevent other users from reading the credentials.

Create a database and a least-privilege application user

Create the schema and account

Open an administrative MySQL session, then create a schema and an account whose host is limited to the machine where the application runs:

sudo mysql

CREATE DATABASE appdb;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'use-a-secret-manager-or-prompt';
GRANT SELECT, INSERT, UPDATE, DELETE ON appdb.* TO 'appuser'@'localhost';

The example grants the four data-manipulation permissions commonly needed by a simple runtime account. Replace the names and secret-handling method for your deployment. A framework that creates or alters tables may need additional data-definition permissions during a migration; grant those temporarily to a separate migration account or remove them after the migration rather than making the runtime account permanently administrative.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand privilege scope

MySQL privileges can apply globally, to one database, to individual tables, to columns, or to stored routines. The broad form ON *.* affects every database and should not be the default for an application. The narrower ON appdb.* confines access to one schema.

Be especially cautious with:

  • FILE, which can allow interaction with files on the server host.
  • Administrative privileges that can change server operation or inspect other workloads.
  • GRANT OPTION, which lets an account delegate its own privileges to other accounts.

Oracle’s MySQL 8.4 Reference Manual summarizes the rule plainly: “It is a good idea to grant to an account only those privileges that it needs.” List the resulting grants when auditing an account:

Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
SHOW GRANTS FOR 'appuser'@'localhost';

Separate human, runtime, and migration access

Do not make every developer or application use the MySQL root account. Give each service its own named account, and give human operators individual accounts where practical. This makes revocation and audit trails possible. A deployment process that runs schema migrations can use a short-lived account with the extra DDL rights it needs, while the application process continues using its restricted runtime account.

Decide whether MySQL should accept network connections

Keep a same-VPS application local

If your application and database are on the same VPS, leave MySQL listening on the local interface. Local-only operation avoids exposing port 3306 to scanners and removes an entire class of firewall and authentication mistakes. An application can connect through the local socket or loopback address without any public DNS record or inbound database rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote access requires several controls

Changing MySQL’s bind-address to a non-local interface is justified only when a client genuinely runs elsewhere. Ubuntu stores package configuration under /etc/mysql; locate the active server configuration, change the bind address there, and restart only after validating the file:

grep -R "^[[:space:]]*bind-address" /etc/mysql
sudo systemctl restart mysql.service
sudo systemctl status mysql

Do not “fix” a connection by opening port 3306 to every IPv4 and IPv6 address. Prefer an SSH tunnel or a private network for administration. If a public or routed connection is unavoidable, combine all of these controls:

  • Bind only to the required interface.
  • Allow the port in the firewall only from known source addresses or a tightly defined subnet.
  • Create MySQL accounts with a host restriction matching the intended client, rather than a blanket wildcard host.
  • Use secure authentication and TLS appropriate to the environment.
  • Monitor failed connections and remove the rule when the remote task ends.

Use Ubuntu’s firewall without locking yourself out

Ubuntu identifies ufw as its default firewall configuration tool. Preserve your SSH access before enabling or editing rules. A source-restricted rule is safer than a global allow; adapt the address and port to your network:

sudo ufw status verbose
sudo ufw allow from 203.0.113.25 to any port 3306 proto tcp
sudo ufw enable

The address above is an example documentation range, not a recommendation to copy blindly. If the database is local-only, do not add a 3306 allow rule at all. Check the effective rules after every change and test from the real client network.

Rank #4
Sale
WD 2TB Elements Portable External Hard Drive for Windows, USB 3.2 Gen 1/USB 3.0 for PC & Mac, Plug and Play Ready - WDBU6Y0020BBK-WESN
  • High capacity in a small enclosure – The small, lightweight design offers up to 6TB* capacity, making WD Elements portable hard drives the ideal companion for consumers on the go.
  • Plug-and-play expandability
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • SuperSpeed USB 3.2 Gen 1 (5Gbps)

Choose a backup method that matches your recovery need

Backups are a recovery system, not merely an export file. MySQL’s documentation lists system crashes, hardware failures, accidental deletion, upgrades, migrations, and replica setup as reasons to maintain backups. Decide what you can lose, how quickly service must return, and where a copy can survive loss of the VPS.

Method What it produces Best fit described in the documentation Important trade-off
mysqldump Logical SQL text Smaller databases and editable SQL restores Restore time grows with the amount of SQL to execute
MySQL Shell Dump Utility Programmatic logical backup with filtering Logical backups that need filtering or automation Requires learning the Shell utility and its output workflow
Percona XtraBackup Physical backup of database files Larger production databases where backup performance matters Physical backup and restore procedures are more operationally involved

Logical and physical methods are not mutually exclusive. A smaller VPS may use logical dumps for portability and keep a provider snapshot for quick rollback. A larger production workload may add physical backups to reduce recovery time. Provider snapshots are useful only if you know what they include, how long they are retained, and whether you have tested restoring one.

Make a logical backup and protect it

Run a basic dump

For a small schema, the documented pattern is:

mysqldump -u root -p appdb > appdb.sql
mysql -u root -p appdb < appdb.sql

The -p option prompts for the password; it does not put the secret in the command text. Use an account with the dump privileges required by your objects rather than assuming the application account can export everything. Protect the resulting file because it contains the data in a readily readable form:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chmod 600 appdb.sql

For a real schedule, decide which schemas and objects are included, how often jobs run, how many generations remain, and how failures are reported. Encrypt dumps before sending them to storage outside the VPS. Keep at least one copy separated from the server; a removable external drive can provide an offline copy, but one drive alone is not an off-site, redundant strategy.

Combine fast rollback with independent copies

A practical VPS arrangement is an on-server or attached snapshot for rapid rollback, plus encrypted logical dumps copied to separate storage. Keep copies in a different failure domain, such as removable media or a WAN/off-site location. Document the credentials and encryption-key recovery path separately from the backup files; an encrypted backup without its key is not a usable recovery asset.

Prove that restoration works

A successful dump command proves only that a file was written. It does not prove that the file is complete, readable, or suitable for your application’s recovery time. Periodically restore into a disposable database or staging VPS:

  1. Create an isolated target that cannot overwrite production data.
  2. Restore the dump with the same class of MySQL version and account privileges you expect to use during an incident.
  3. Check that tables, row counts, users or grants required by the application, and representative queries work.
  4. Start the application against the restored database and exercise a login, a read, and a write path.
  5. Record elapsed restore time, missing steps, and the next action needed to improve the runbook.

Restore rehearsals are an operational recommendation rather than a universal calendar requirement; set the interval according to how damaging data loss would be and how often your schema changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Back up configuration before maintenance

Database contents are only part of a recoverable MySQL installation. Before an invasive upgrade or configuration edit, preserve the package configuration and a database backup. Ubuntu’s package configuration is under /etc/mysql; a simple archive can capture the text settings:

sudo tar -czf mysql-config-$(date +%F).tgz /etc/mysql

Do not copy a live MySQL data directory as if it were a consistent backup. Use a supported physical-backup tool, a provider snapshot designed for the workload, or stop the service when your chosen procedure requires a quiescent filesystem copy. Keep configuration archives with controlled permissions because they may reveal topology or authentication settings.

Maintain the service without guessing at tuning

Change one setting at a time

Keep custom values in the package-supported MySQL configuration locations rather than scattering ad-hoc files. Back up /etc/mysql and the database before invasive changes. When a setting requires a restart, use:

sudo systemctl restart mysql.service
sudo systemctl status mysql
sudo journalctl -u mysql

Do not copy tuning values from an unrelated VPS. Useful settings depend on available memory, storage latency, query shape, concurrency, and the application’s workload. Measure before and after a change, and keep a record so you can revert a setting that increases latency or causes startup failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use status and logs as your first diagnostic branch

  • Service inactive after installation: inspect systemctl status mysql, then read journalctl -u mysql for the first configuration or permission error.
  • MySQL starts but the application cannot connect locally: verify the socket or loopback settings, the account host component, the selected database, and the account’s grants.
  • Remote client times out: check the bind address, the VPS firewall, any upstream provider firewall, and whether the client source address is actually allowed.
  • Remote client is refused immediately: confirm that MySQL is listening on the intended interface and port; a firewall change cannot make a service listen where it is not bound.
  • Restore fails: capture the exact error, verify dump-file integrity and permissions, confirm target version compatibility, and repeat in an isolated environment rather than experimenting against production.

A repeatable VPS checklist

  1. Install MySQL with sudo apt install mysql-server.
  2. Verify the service and inspect the journal if it is not active.
  3. Run the initial security workflow and confirm administrative access.
  4. Create one schema and separate named accounts for runtime, migration, and human administration as appropriate.
  5. Grant only the required schema, table, column, or routine privileges; avoid broad administrative rights and GRANT OPTION.
  6. Keep MySQL local unless a documented remote requirement exists.
  7. If remote access is required, constrain binding, MySQL host matching, firewall sources, and authentication together.
  8. Choose logical, physical, or combined backups based on database size and recovery-time needs.
  9. Schedule backups, encrypt copies, retain them separately from the VPS, and document key recovery.
  10. Perform restore rehearsals and back up /etc/mysql before major changes.

Following this sequence gives a beginner a manageable MySQL installation without treating convenience as security or a successful export as proof of recoverability.

Quick Recap

Bestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$219.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.