Your own MySQL server: phpMyAdmin, command line and code

Create a free MySQL (MariaDB) server on Torchlite, find its address, user and password, and connect from phpMyAdmin, the mysql command line, Node.js and Python.

4 min readBy Torchlite teamUpdated

Your own MySQL server: phpMyAdmin, command line and code
On this page

The Database plan gives you a whole MySQL server of your own. It runs MariaDB 11.4, which speaks the MySQL protocol, so phpMyAdmin, the mysql client and every MySQL driver work with it. This guide creates the server, finds the connection details and connects three ways.

One thing first: the connection has no TLS, so the password and your data travel unencrypted. Use it for game servers, bots and hobby projects, not for sensitive personal data. This is not the single database on the Databases tab of a game server; that one is covered in MySQL database for your game server.

Create the server

  1. Open Create your server and pick the Database plan, then MySQL (MariaDB).
  2. Confirm your email with the code we send.
  3. In the panel at game.torchlite.host, press Start in the Console. The first start creates the database files and takes about half a minute.
  4. Wait for the line "MariaDB is ready on port". That is the only thing the console says.

The plan has 768 MB of RAM, half a core and 5 GB of disk. You renew it every 48 hours, and the Renew button opens 12 hours early. See the renewal guide.

Find the address, user and password

  • Address: the panel shows data.torchlite.host:<port>, with a port between 17000 and 17499. The examples here use data.torchlite.host:17023. Use the values from your own panel.
  • User: open Startup. The variable User shows admin. It cannot be renamed.
  • Password: the variable Password under Startup. It was generated when the server was created.
  • First database: main.

The admin account has all privileges and can create more users and databases. The local root account has no network access.

Connect from phpMyAdmin

  1. Open https://db.torchlite.host.
  2. In the Server field, type the host name, a space and the port: data.torchlite.host 17023.
  3. Type admin as the user and your password, then log in.

You see main in the list on the left. Create tables there, import a .sql file or add users.

Connect from the command line

With the mysql or mariadb client installed on your computer:

bash
mysql -h data.torchlite.host -P 17023 -u admin -p main

It asks for the password. Use -h for the host and a capital -P for the port. Once connected, you can create a second database and a user for an app:

sql
CREATE DATABASE shop;
CREATE USER 'shopapp'@'%' IDENTIFIED BY 'a-long-password';
GRANT ALL PRIVILEGES ON shop.* TO 'shopapp'@'%';

A separate user per app means you can change or remove one without touching the others.

Connect from code

Node.js with the mysql2 package (npm install mysql2):

js
const mysql = require("mysql2/promise");

async function main() {
  const db = await mysql.createConnection({
    host: "data.torchlite.host",
    port: 17023,
    user: "admin",
    password: process.env.DB_PASSWORD,
    database: "main",
  });
  const [rows] = await db.query("SELECT NOW() AS now");
  console.log(rows);
  await db.end();
}
main();

Python with pymysql (pip install pymysql):

python
import os
import pymysql

db = pymysql.connect(
    host="data.torchlite.host",
    port=17023,
    user="admin",
    password=os.environ["DB_PASSWORD"],
    database="main",
)
with db.cursor() as cur:
    cur.execute("SELECT NOW()")
    print(cur.fetchone())
db.close()

Keep the password in an environment variable, not in your code or in a Git repository.

Change the password

Open Startup, edit Password and restart the server. The new password is applied on every start. It must be 12 to 64 letters and digits. Update it in your apps too.

Tune my.cnf

The first start creates my.cnf in the server's files. These are the defaults:

SettingDefault
innodb_buffer_pool_size128M
max_connections40
performance_schemaoff

The file also holds a few smaller buffers and the utf8mb4 character set. Edit it in Files, then restart. Keep the numbers modest: the plan has 768 MB of RAM in total, and a buffer pool larger than the memory left can make the server stop. The port, the data folder and the security options are set by us at every start and win over the file.

Two limits to know: LOAD DATA LOCAL is off, and the local root account cannot be used from the network.

Backups

Backups from the panel copy the files, so make them while the server is stopped. Or dump from your computer while it runs:

bash
mysqldump -h data.torchlite.host -P 17023 -u admin -p --all-databases > backup.sql

If your computer has mariadb-dump instead, use that name. A reinstall of the server keeps the data.

Common problems

Typing in the Console does nothing

The Console only shows the log. Typing does nothing except stop. Use the Data tab in the panel, phpMyAdmin or a client instead.

Access denied for user admin

The password is wrong. Copy it again from Startup. If you changed it there, the new one only applies after a restart.

Can't connect to server

Check that the server is running, that the port is the one in the panel, and that your own network allows outgoing connections to it. The server stops when the renew time runs out. Press Renew, then Start.

phpMyAdmin says it cannot connect

The Server field needs the host name, a space and the port, with no colon. Type data.torchlite.host 17023.

MariaDB did not start after I edited my.cnf

A wrong line in my.cnf is the usual cause. The Console shows the log lines that explain it. Fix the line, or delete the file: the next start writes the defaults again.

Start refuses my password

It must be 12 to 64 letters and digits. Symbols and spaces are refused.

I need to switch to another engine

Use Change engine in the panel. The MySQL data is deleted, not converted, so export it first.

Stuck on a step?

Ask on the forum. Your question links back to this guide, so whoever answers knows where you are.

Ask about this guide

About the author

Torchlite team

The people who run Torchlite

We build and run the Torchlite panel and the nodes. Every guide is checked on our own servers before it goes up, and updated when the panel changes.

Found a mistake? Tell us on Discord

Related guides

All guides →