Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesFor a beginner, safe MySQL administration on a VPS follows a predictable order: install the operating-system package, verify and secure the service, create a narrowly privileged application account, keep port 3306 private unless remote access is genuinely required, and build backups that you have actually restored. The commands and decisions below use Ubuntu as the example and apply the same principles to other Linux distributions with different package commands.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What MySQL does on a VPS
MySQL is a database server: it stores structured information in databases, tables, rows and columns, and answers SQL queries from applications or administrators. On a VPS, the server process runs continuously in the background while your website, game service, API or other program connects to it over the local machine or a network.
As an Amazon Associate I earn from qualifying purchases.
There are three identities to keep separate:
- Linux
root: the operating-system administrator who can install packages, edit configuration and control services. - MySQL
root: a database account with broad MySQL privileges. It is not automatically the same credential as Linuxroot. - Application accounts: named MySQL users used by your software, each limited to the schema and operations it needs.
MySQL identifies an account by both a user name and a client host, such as 'appuser'@'localhost'. That host part is an access rule, not a comment: an account created for localhost is different from one created for a remote address.
Install MySQL on Ubuntu
1. Install the distribution package
Update the package index, then install Ubuntu’s MySQL server package:
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
sudo apt update
sudo apt install mysql-server
The package normally starts the service after installation. Installing from the operating-system repository gives you service integration, security updates and a configuration layout that Ubuntu’s maintenance tools understand.
2. Verify that the service is running
Check either the traditional service interface or systemd directly:
Recommended Free Tools
sudo service mysql status
sudo systemctl status mysql
A healthy result shows an active running service. If it is stopped or failed, inspect the service journal before changing settings:
sudo journalctl -u mysql
Look for the first error rather than the final cascade of messages. Common causes include a malformed configuration line, an unavailable data directory, insufficient disk space or a port already in use.
3. Complete the initial security work
After installation, follow MySQL’s post-installation workflow: start the server, test administrative access, secure the initial MySQL root account, and arrange automatic startup if it is not already enabled. On Ubuntu installations this is commonly performed with the package’s interactive security script:
sudo mysql_secure_installation
Read every prompt instead of accepting a copied answer. Remove anonymous accounts and test databases if the wizard offers those choices, set an authentication method and password appropriate to your deployment, and avoid using the administrative account in application configuration.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Do not put a database password directly in a shell command that can be exposed through shell history or process listings. Prefer an interactive password prompt, a protected option file, or MySQL’s login-path mechanism with permissions that prevent other users from reading the secret.
Create a database and a least-privilege application user
1. Create the schema
Connect as an administrative MySQL account, then create a database for one application:
sudo mysql
CREATE DATABASE appdb;
EXIT;
If your application requires a character set or collation, specify those deliberately in the CREATE DATABASE statement and keep the choice consistent with the application’s documentation. The important operational boundary is that the application has its own schema instead of sharing an unrestricted account across unrelated projects.
2. Create a user tied to the local host
For software running on the same VPS, create the account with a local host restriction:
sudo mysql
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'use-a-secret-manager-or-prompt';
Replace the example secret with a strong value supplied through your secret-management process. Never publish the literal example password or reuse an administrator’s password.
3. Grant only the required operations
A typical runtime account needs data manipulation on its own schema, not server-wide authority:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
GRANT SELECT, INSERT, UPDATE, DELETE ON appdb.*
TO 'appuser'@'localhost';
Privileges can be scoped globally, to a database, table, column or routine. ON appdb.* limits this grant to every table in appdb; ON *.* would apply to every database on the server and is usually excessive for an application.
Choose permissions from the application’s real workload. A read-only reporting process may need only SELECT. A job that creates tables during a controlled migration may temporarily need additional DDL privileges, but those rights should not automatically remain on the account used by the running application.
Privileges that deserve special caution
FILEcan allow operations involving files on the server host and should not be granted casually.- Administrative privileges can change server operation or bypass normal application boundaries.
GRANT OPTIONlets an account delegate its privileges to other accounts, expanding the blast radius of a stolen credential.
MySQL’s documented principle is simple: grant an account only the privileges it needs. Record the grants you intentionally chose so that a later migration or troubleshooting session does not become an excuse to make the account unrestricted.
Keep MySQL private unless remote access is necessary
Local-only is the safest default
If the application and MySQL run on the same VPS, keep MySQL listening on the local interface. The application can connect through localhost or the local socket without exposing the database to the public internet. This removes an entire class of scanning and password-guessing traffic and makes the host part of the MySQL account meaningful.
Do not open TCP port 3306 merely because a client cannot connect. First check the application’s host name, credentials, socket-versus-TCP behavior and local service status.
When remote connections are justified
Remote access may be required for a separate application server, a private administration network or a managed monitoring system. In that case, change MySQL’s bind-address in the package-supported configuration location so the server listens on the required private interface rather than every interface. Restart after validating the file:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
sudo systemctl restart mysql.service
sudo systemctl status mysql
Use an account whose host restriction matches the intended client address or private network. A remote listener alone does not authorize a user, and a MySQL grant alone does not make a network path safe.
Protect the network path
- Prefer an SSH tunnel for occasional administration. It keeps 3306 off the public interface while allowing a local database client to reach the VPS through authenticated SSH.
- Use a private network when two servers need ongoing communication and your provider supplies one.
- If direct exposure is unavoidable, restrict the firewall rule to known source addresses or a tightly controlled subnet, use secure authentication and TLS appropriate to the environment, and monitor failed connections.
Ubuntu’s default firewall tool is ufw. Preserve your current SSH access before enabling or changing firewall rules; a rule that blocks your administration path can lock you out of the VPS.
sudo ufw status
sudo ufw allow from 203.0.113.10 to any port 3306 proto tcp
sudo ufw status verbose
Replace the example address with the actual trusted source. Never substitute 0.0.0.0/0 for convenience. If the source address changes frequently, use a private network or SSH rather than repeatedly widening the rule.
Back up MySQL as a recovery system
Why a successful backup command is not enough
Backups protect against system crashes, hardware failures, accidental deletion, upgrades, migrations and other events that can make the live data unavailable. A backup is useful only if you know what it contains, where copies are stored, how long they are retained and how to restore it.
Write down the recovery objective before choosing a tool:
- Recovery point: how much recent data can you afford to lose?
- Recovery time: how quickly must the service be usable again?
- Scope: do you need one schema, every schema, users and grants, configuration, or the entire VPS?
- Storage failure: what happens if the VPS disk and its local backup disappear together?
Choose logical or physical backups
| Method | What it produces | Good fit | Trade-offs |
|---|---|---|---|
mysqldump |
Logical SQL statements | Small databases, portable or editable restores | Restore time grows with data size; output must be protected like the database |
| MySQL Shell Dump Utility | Programmatic logical dump with filtering options | Logical backups that need more control than a basic dump | More options to understand and operate correctly |
| Percona XtraBackup | Physical backup of database files | Larger production databases where backup and restore performance matters | More operational complexity and tighter version/storage planning |
Logical backups are easy to inspect and move between compatible environments. Physical backups can reduce recovery time for large data sets but require a process suited to the MySQL version, storage layout and backup tool.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Create and restore a small logical backup
For a small schema, the basic pattern is:
mysqldump -u root -p appdb > appdb.sql
mysql -u root -p appdb < appdb.sql
Enter the password at the prompt rather than appending it to the command. Use an account with the dump privileges required by your schema, protect the resulting file with restrictive filesystem permissions, and avoid storing it in a publicly served directory.
Free tools Windows power users keep installed
One-click scans. No signup required.
For a production backup, account for routines, triggers, events, character sets, transaction consistency and all schemas your application needs. If users, grants or server configuration are part of recovery, back them up separately or include them in a documented export process; a schema dump alone does not recreate the whole VPS.
Store copies separately and rehearse recovery
A practical VPS arrangement combines a fast local recovery copy with encrypted copies on separate storage. An attached or on-server snapshot can speed recovery from a routine mistake, while an encrypted dump copied to another system, removable media or an off-site location protects against loss of the VPS itself. One external hard drive is not an off-site strategy if it remains beside the server and is never rotated.
Schedule the job at a frequency that matches your recovery-point requirement, retain multiple generations, encrypt data in transit and at rest, and restrict who can read the backup location. Periodically restore into a disposable database or staging VPS, then verify that the application can connect and that important records are present. The restore rehearsal is the evidence that your procedure works; a log saying “dump completed” is not.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Manage configuration without locking yourself out
Back up configuration before invasive changes
Database contents are only part of a recoverable service. Preserve the package-managed MySQL configuration, including /etc/mysql, along with your backup and deployment notes. Before changing bind addresses, authentication settings, storage paths or tuning values, make a dated copy and confirm that you can reverse the change.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →sudo cp -a /etc/mysql /etc/mysql.backup-$(date +%F)
Keep custom settings in the configuration locations supported by the Ubuntu package instead of editing generated files or scattering undocumented overrides. After a setting change, restart only when that setting requires it and immediately inspect service status and the journal.
Do not copy tuning values blindly
There is no universal VPS size or safe tuning profile established for every workload. Useful values depend on available memory, storage latency, query shape, concurrency, indexes and traffic patterns. Measure before and after a change, alter one category at a time, and keep the previous configuration so you can roll back when startup or performance worsens.
Troubleshoot the failures beginners meet first
The service will not start
- Run
sudo systemctl status mysqlfor the immediate failure state. - Read
sudo journalctl -u mysqland identify the earliest specific error. - Check recent configuration edits, disk space, ownership of the data directory and whether another process is using the expected port.
- Restore the last known-good configuration copy if the failure began after a change, then restart and verify again.
The application receives “access denied”
- Confirm the user name, password and host portion of the account;
'appuser'@'localhost'and'appuser'@'203.0.113.10'are different accounts. - Confirm that the application is connecting to the intended database and that the account has the needed privileges on that schema.
- Check whether the application uses a Unix socket while your test uses TCP, or the reverse.
- Do not solve an authorization error by granting
ALL PRIVILEGES ON *.*; correct the account, host or narrowly scoped grant.
A remote client cannot connect
- Verify that MySQL is bound to the intended private interface, not only
localhost. - Confirm that the service was restarted after the configuration change.
- Check the VPS firewall and any provider-level firewall for a rule limited to the real source address.
- Confirm that the MySQL account’s host restriction permits that client.
- If the connection is for administration, replace public exposure with an SSH tunnel or private network where possible.
A restore completes but the application is broken
Check that the dump included every required schema, table, routine, trigger and event, and that the restored account and grants exist. Compare character-set and collation settings, verify application configuration points to the restored host and database, and run a small set of real read and write checks in staging before switching production traffic.
A repeatable operating checklist
- Install MySQL from the Ubuntu package and verify the service.
- Complete initial account-security steps and keep administrator credentials out of application files.
- Create one database and one application account per workload where practical.
- Grant only the required database, table, column or routine privileges.
- Keep 3306 local unless a documented requirement needs remote access.
- If remote access is required, restrict bind address, MySQL host grants, firewall sources and authentication.
- Back up database contents, users and grants as appropriate, plus
/etc/mysqland deployment configuration. - Keep encrypted copies separate from the VPS and retain more than one generation.
- Perform restore tests and record the exact commands and prerequisites.
- Review logs, disk space, backup freshness and failed connection attempts as part of routine maintenance.
This sequence gives a small VPS a defensible baseline: the service is installed and observable, applications are not administrators, the database is not unnecessarily public, and recovery is a practiced operation rather than a hopeful command typed after a failure.
Quick Recap
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.




