Skip to content

MySQL on a VPS

SQL database by Oracle

Category
Databases
Hosting
Databases
Author
Oracle
License
GPL-2.0
Version
9.7.2

The script is free · VPS from $4.63 per month · installs in about 2 minutes

Install over SSH

root@vps:~# command -v docker >/dev/null || curl -fsSL https://get.docker.com | sh; P=$(openssl rand -hex 16); echo "$P" > /root/mysql-root-password && chmod 600 /root/mysql-root-password && docker run -d --name mysql --restart unless-stopped -p 127.0.0.1:3306:3306 -e MYSQL_ROOT_PASSWORD=$P -v mysql-data:/var/lib/mysql mysql:lts

  • SystemUbuntu 24.04 · x86_64ok
  • Sourcegithub.com/mysql/mysql-serverok
  • Version9.7.2ok
  • Port3306/tcplisten

✓ MySQL 9.7.2 installed · about 2 minutes

root@vps:~#

Install command from the library. Output is shortened and may differ on your server.

What it is

  • SQL
  • Database
  • WordPress
  • PHP

MySQL is one of the most popular SQL databases. It powers WordPress, most PHP projects, many CMSs and bots.

Your own database on a VPS gives you full control over settings, backups and performance. It is convenient to keep it next to your app and not expose it publicly.

The command runs the official Docker image of the LTS branch. The port is open on localhost only, and a random root password is saved to /root/mysql-root-password.

  • Compatible with WordPress, Laravel and most PHP projects
  • InnoDB engine with transactions
  • Replication and backups via mysqldump
  • LTS branch with long-term support
  • Port closed to the outside by default

Recommended plan

For MySQL: at least 2 vCPU, 3 GB RAM and 45 GB NVMe.

Minimum to run
1 vCPU · 1 GB RAM · 10 GB disk
Systems
Ubuntu 22.04 · Ubuntu 24.04 · Debian 12

How to install

Three steps in the bot or one command over SSH; installation takes about 2 minutes.

  1. 01

    Choose a plan in the bot

    Open @ExpressHost_bot and pay for a VPS. The server will be ready in about 60 seconds.

  2. 02

    Add MySQL

    At the “Add-ons” step pick the script from the library, or run it later: Server settings → Scripts.

  3. 03

    The root password is in /root/mysql-root-password

    The bot will send the server address and login details to the chat.

Manually over SSH

Connect to the server as root and run the command. Supported systems: Ubuntu 22.04, Ubuntu 24.04, Debian 12.

Install command
command -v docker >/dev/null || curl -fsSL https://get.docker.com | sh; P=$(openssl rand -hex 16); echo "$P" > /root/mysql-root-password && chmod 600 /root/mysql-root-password && docker run -d --name mysql --restart unless-stopped -p 127.0.0.1:3306:3306 -e MYSQL_ROOT_PASSWORD=$P -v mysql-data:/var/lib/mysql mysql:lts

Ports

MySQL ports
PortProtocolPurpose
3306tcpDatabase connections (127.0.0.1 only)

After installation

  1. 1.The root password is in /root/mysql-root-password
  2. 2.Open the console: docker exec -it mysql mysql -uroot -p
  3. 3.Create a database and user for your app: CREATE DATABASE app; CREATE USER 'app'@'%' IDENTIFIED BY 'password'; GRANT ALL ON app.* TO 'app'@'%';

MySQL FAQ

Didn’t find an answer? Message @ExpressHost_SupportBot.

How do I connect from my computer?

The port is open only on the server. Use an SSH tunnel: ssh -L 3306:127.0.0.1:3306 root@IP.

How do I make a backup?

docker exec mysql sh -c 'mysqldump -uroot -p"$MYSQL_ROOT_PASSWORD" --all-databases' > backup.sql

Where is the data stored?

In the mysql-data Docker volume (the /var/lib/mysql folder inside the container).

MySQL installs at checkout — in the bot.