MySQL, MariaDB and PostgreSQL
The three relational engines work the same way in the dashboard. This page shows you how to create a user and a database, and how to connect to the database from a client in your lab.
1. Create a user
- Go to Services and select Manage on MySQL, MariaDB or PostgreSQL.
- Select Add User (or Create User if you have none yet).
- Fill in Username, Password and Confirm Password, then confirm.
| Field | Rules |
|---|---|
| Username | 5–16 characters: letters, digits and underscores. Not only digits, and not a reserved name such as root. |
| Password | At least 8 characters. Single quotes (') are not allowed. |
The user appears as a card on the Dashboard tab, with its password behind a copy button.
2. Create a database
- Open the Database tab.
- Choose the Username that will own it.
- Type a Database Name. It is automatically prefixed with the user's name
and an underscore, so
shopowned byalice_devbecomesalice_dev_shop. - On MySQL and MariaDB, choose a Collation (if you are not sure, leave the default).
- Select Create Database.
The part you type must be at least 5 characters long, and the full name, including the prefix, can be at most 64 characters. Each user card shows how many databases the user owns and how many it can own. At the limit, you see Database limit exceeded for the user.
3. Connect from your lab
Copy the Hostname and Port from Connection Information on the service's Dashboard tab. Then, in your lab's terminal:
MySQL / MariaDB
sudo apt-get install -y mysql-client # or mariadb-client
mysql -h <host> -P <port> -u <user> -p <database>
From code, the usual connection URL is:
mysql://<user>:<password>@<host>:<port>/<database>
PostgreSQL
sudo apt-get install -y postgresql-client
psql -h <host> -p <port> -U <user> -d <database>
From code:
postgresql://<user>:<password>@<host>:<port>/<database>
Enter the password from the user's card when asked. Remember that <database> is
the full, prefixed name.
Anything you apt-get install is gone after a redeploy. Add the client install
to your startup script.
Managing what you created
| Task | Where |
|---|---|
| See a user's password | Its card on the Dashboard tab |
| Drop a database | Its card on the Database tab |
| Delete a user | Delete User on its card — this also deletes every database it owns |
If it does not connect
| Symptom | Check |
|---|---|
| Access denied | The username and password match the card exactly, and you are using the prefixed database name |
| Connection times out | You are connecting from inside a lab, with the host and port from the service page. From your own computer, use the port forwarding helpers. |
| Unknown database | The database name includes the <user>_ prefix |
Do it with an AI assistant
You can also do this by asking an AI assistant connected to your account — see Connect an AI assistant to set one up.
| Ask | What the assistant does |
|---|---|
| “Create a PostgreSQL user called appsvc01” | add_service_user |
| “Create a database called orders for appsvc01” | create_database — the platform names it appsvc01_orders |
| “What databases does appsvc01 have?” | list_databases |
| “Drop appsvc01_orders” | delete_database |
An assistant cannot read back a MySQL, MariaDB or PostgreSQL password. Copy it from the user's card on the service page. When you create a database, give only the name; the platform adds the user prefix.
How to connect MySQL to VS Code via Selfmade Ninja Labs is a step-by-step guide with screenshots.
Next
- Databases and services — limits, port forwarding, public endpoints
- MongoDB