DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk8 min

MySQL Basics for Beginners: Managing Databases on Your VPS

A practical beginner’s guide to installing MySQL on Ubuntu, creating secure application accounts, controlling network access, and restoring tested backups on a VPS.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a beginner, the safest VPS setup is straightforward: install MySQL from Ubuntu’s package, verify and harden the service, create a separate least-privilege account for each application, keep port 3306 private unless remote access is genuinely required, and operate backups as a tested recovery system rather than as occasional dump files.

What MySQL does on a VPS

MySQL is a database server: it stores structured application data, answers SQL queries, enforces permissions, and keeps data available to software running on your VPS. A VPS gives you operating-system control, but it also makes you responsible for updates, account security, network exposure, storage capacity, and recovery. MySQL’s Linux root account and MySQL’s own root account are different identities. The former can administer the server through Ubuntu; the latter is a database account whose permissions and authentication are managed by MySQL.

As an Amazon Associate I earn from qualifying purchases.

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.

MySQL identifies an account by both username and client host. Thus 'appuser'@'localhost' is a different account from 'appuser'@'203.0.113.10'. That host component is an important security control: an account intended for a local application should not automatically be usable from every network address.

Prepare the VPS before installation

  • Use a supported Ubuntu Server release and log in through SSH with an administrative account that can run sudo.
  • Keep a second SSH session open while changing firewall or service settings, so a mistake does not lock you out.
  • Confirm that the VPS has enough free storage for the operating system, MySQL data, binary logs if enabled, and backup files. Database growth, not a generic VPS size, should determine capacity.
  • Apply pending Ubuntu security updates before exposing any new service.
  • Decide whether the application and MySQL will run on the same VPS. Local-only operation is the safer default and avoids opening 3306 at all.

Install MySQL on Ubuntu

  1. Install the distribution package. Run sudo apt install mysql-server. Ubuntu’s package normally starts the service after installation.
  2. Check the service. Use sudo service mysql status or sudo systemctl status mysql. A running service should show an active state rather than a failed one.
  3. Inspect startup failures. If the service is not active, read recent messages with sudo journalctl -u mysql. Look for configuration syntax errors, unavailable storage, permission problems, or a port already in use before attempting random changes.
  4. Complete the initial hardening workflow. Run the Ubuntu/MySQL hardening utility, commonly sudo mysql_secure_installation, and review every prompt. Remove anonymous accounts, prevent remote use of the administrative account where offered, remove the test database if it is not needed, and reload privilege information.
  5. Confirm automatic startup. Ubuntu packages generally enable MySQL at boot. Verify with sudo systemctl is-enabled mysql; enable it with sudo systemctl enable mysql if your installation is not configured to start automatically.

Do not put a database password directly in a shell command or a script visible to other users. Use the interactive password prompt, a protected option file, or MySQL’s login-path mechanism with permissions that prevent other accounts from reading the secret.

#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.

Understand the two root accounts

Ubuntu’s operating-system root can read files, control services, and change firewall rules. MySQL’s root can perform database administration. They may use different authentication methods; on Ubuntu, local administrative access may be tied to the operating-system account through socket authentication. Test local administration with sudo mysql rather than assuming that a password-based login will work. Do not use the MySQL root account in application configuration.

Create a database and an application user

Connect locally as an administrator, then create the schema and a dedicated account. Replace the names and secret-handling method for your deployment:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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';

Exit with EXIT;. The application should connect as appuser, not as MySQL root. The example grants the four data-manipulation privileges commonly needed by a running application, but the correct set depends on the software. An application that creates or alters tables during migrations may temporarily require DDL privileges such as CREATE or ALTER. A safer pattern is to use a separate migration account or grant those rights only for the migration window, then remove them from the permanent runtime account.

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.

Choose the narrowest privilege scope

MySQL privileges can apply globally, to one database, to individual tables or columns, or to stored routines. Granting on appdb.* confines the account to one schema; granting on *.* covers every database on the server and is rarely appropriate for an application.

Scope Example Use and risk
Global ON *.* Server-wide operation; reserve for carefully controlled administrators.
Database ON appdb.* Normal application boundary when one account owns one schema.
Table ON appdb.orders Useful when a service must see only selected tables.
Column Specific columns in a table Can hide sensitive fields, but requires more maintenance.
Routine Stored procedure or function privileges Useful for controlled database APIs.

Be especially cautious with FILE, administrative privileges, and GRANT OPTION. FILE can expose or write files accessible to the server process; administrative privileges can change server operation; GRANT OPTION lets an account delegate its privileges. MySQL’s documented principle is to grant an account only the privileges it needs.

Review an account with:

SHOW GRANTS FOR 'appuser'@'localhost';

When an employee, service, or deployment is retired, remove its account or privileges deliberately rather than leaving credentials active indefinitely.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Keep MySQL private unless remote access is required

Local application on the same VPS

If your web application runs on the same machine, configure MySQL to listen only on the local interface. A local account such as 'appuser'@'localhost' and a local connection avoid exposing 3306 to the internet. Do not open the port merely because a client tool cannot connect from your laptop; use an SSH tunnel for administration instead.

Remote administration or a separate application host

When a real remote client is required, change MySQL’s bind-address in the package-supported configuration under /etc/mysql/. Bind to a private interface or a specific address rather than all interfaces, then restart with sudo systemctl restart mysql.service. Create an account whose host restriction matches the known client address or private subnet; avoid a wildcard host unless you fully understand the exposure.

Ubuntu identifies ufw as its default firewall tool. Preserve SSH before enabling or changing rules:

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)
sudo ufw allow OpenSSH
sudo ufw status verbose

A source-restricted rule can permit only a known administration host:

sudo ufw allow from 203.0.113.10 to any port 3306 proto tcp

Use your actual fixed address or private network, not the documentation address above. If addresses change frequently, prefer an SSH tunnel or private network instead of broadening the firewall. Remote connections should use secure authentication and TLS appropriate to the environment. Limiting network reachability is not a substitute for least-privilege accounts; both controls are needed.

Back up MySQL as a recovery system

Backups address system crashes, hardware failures, accidental deletion, upgrades, migrations, and replica setup. Oracle’s MySQL documentation stresses that the purpose is to recover and be running again, not merely to possess a file. Plan what is backed up, how often it runs, where copies are stored, how long they are retained, and how restoration will be performed.

Choose a backup method

Method Best fit Characteristics
mysqldump Small databases and simple VPS deployments Built-in logical export; produces editable SQL and is easy to inspect and restore, but can take longer on large datasets.
MySQL Shell Dump Utility Filtered or programmatic logical backups Supports more advanced logical-dump workflows than a basic single-command export.
Percona XtraBackup Larger production databases where backup performance matters Physical backup approach; operationally more involved and should be matched to your MySQL version and recovery design.

Logical and physical backups solve different problems. A logical dump is portable and convenient for moving selected schemas. A physical backup can reduce restore time for a large instance but needs compatible storage, tooling, and procedures. VPS-provider snapshots can speed up whole-server recovery, but they should complement database-aware backups rather than replace them; verify what is included, whether snapshots are crash-consistent, and how long they are retained.

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

Make a basic logical backup and restore

  1. Choose an account with the dump privileges required by your schema and protect the destination directory.
  2. Export the database using an interactive password prompt: mysqldump -u root -p appdb > appdb.sql.
  3. Restrict the file so other local users cannot read it, and encrypt it before copying it to storage outside the VPS.
  4. Create the destination database if necessary, then restore with mysql -u root -p appdb < appdb.sql.
  5. Check that tables, row counts, users, application connections, and recent writes behave as expected.

Do not treat a successful dump command as proof of recoverability. A file can be incomplete, unreadable, encrypted with a lost key, or impossible to restore within your outage window.

Use separate copies and rehearse recovery

A practical VPS arrangement keeps a short-term local or attached snapshot for fast rollback, copies encrypted logical backups to separate storage, and periodically restores one into a disposable database or staging VPS. Retain more than one generation and keep at least one copy outside the VPS provider’s failure domain; removable media can help, but a single external drive is not an off-site strategy by itself. Choose a schedule and retention period from your recovery-point and recovery-time requirements rather than from a universal rule. Record the restore steps, credentials or key locations, required MySQL version, and the person responsible for declaring a recovery complete.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Manage configuration and routine maintenance

Keep custom settings in the package-supported MySQL configuration locations instead of editing generated files. Before an invasive change, back up /etc/mysql and the configured MySQL data directory, and note the current service status. After changing a setting that requires a restart, run sudo systemctl restart mysql.service, then immediately check sudo systemctl status mysql and sudo journalctl -u mysql.

Avoid copying tuning values from an unrelated VPS. Memory size, storage latency, query patterns, connection concurrency, indexes, and workload mix determine whether a setting helps or harms performance. Change one variable at a time, measure application behavior, and keep a rollback copy of the previous configuration. Monitor free disk space and database growth because a full volume can stop writes and prevent MySQL from starting cleanly.

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

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

Common problems and fixes

Symptom Likely cause First action
Service is inactive or failed Configuration error, permissions, storage, or port conflict Run sudo systemctl status mysql, then inspect sudo journalctl -u mysql.
Access denied locally Wrong account host, authentication method, or password Test with sudo mysql; run SHOW GRANTS for the exact user/host pair.
Remote client times out MySQL bound locally, firewall blocked, or wrong route Confirm the bind address, source-restricted firewall rule, private-network route, and service restart.
Remote client is refused Nothing is listening on the requested address or port Check service status and listener configuration; do not respond by opening 3306 to everyone.
Restore fails Missing database, privileges, incompatible options, or damaged dump Restore into a disposable environment, read the first SQL error, verify the dump file and required account privileges, and repeat from a known-good backup.
Disk fills unexpectedly Database growth, logs, dumps, or snapshots consuming space Measure each directory, move encrypted backups off-server, and expand or archive storage before MySQL reaches zero free space.

A safe beginner operating checklist

  • Install from Ubuntu’s package and verify that MySQL starts at boot.
  • Complete initial account hardening and keep administrative access separate from application credentials.
  • Create one account per application or service, scoped to the required database and privileges.
  • Keep MySQL local to the VPS whenever possible; use an SSH tunnel for occasional remote administration.
  • If remote access is unavoidable, constrain the bind address, MySQL host pattern, firewall source, and authentication security.
  • Automate encrypted backups, store copies separately, protect keys, and retain multiple generations.
  • Restore periodically into an isolated environment and measure whether the result meets your recovery target.
  • Back up /etc/mysql and the configured data directory before major configuration or version changes.
  • Use service status and journal logs as the first diagnostic tools instead of repeatedly changing settings.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.