Get your free beta license ↗
API operation · databases group
POST

/databases/users/{name}/adopt

First published 30 Nov 20260.2.36Last changed 1 Dec 20260.2.371 change to view
Latest change (release 0.2.37): The operation now returns 409 for accounts with a role, a PROXY privilege, more than one authentication method, a grant on one of MariaDB's own databases, or two grants on the same host for the same database with different privileges.

Assign an existing MariaDB user name to a customer as a database user

Who may call it
AdministratorResellerCustomer
Token scope, any of
databasesall
Answers201 Created

Only administrators can call this operation. Set user to the customer who will own the database user for a MariaDB user name created outside UrbeStack. UrbeStack keeps the account's mysql_native_password hash so applications that sign in with the account keep working. It records grants on the customer's databases as full when the grant includes every privilege on the database, read-only when it includes only SELECT and SHOW VIEW, and custom for any other list of privileges. MariaDB treats an unescaped underscore in a grant as a wildcard. UrbeStack records such a grant for the database whose name matches the name in the grant literally. UrbeStack then applies the recorded grants to every existing account with that name and creates any missing localhost, 127.0.0.1 and ::1 accounts with the same hash. It creates the ::1 account only if IPv6 loopback is available. The operation returns the database user in user.

The API returns 400 if user is missing, is empty or does not identify a customer. It also returns 400 if name is reserved for phpMyAdmin sign-on, matches the name of one of MariaDB's own accounts (root or mysql), or falls outside the allowed format of 1 to 64 ASCII letters, digits or underscores. It returns 404 if MariaDB has no account with that name. It returns 409 if UrbeStack already has a database user with that name, if any account lacks a mysql_native_password hash or has more than one authentication method, or if passwords or grants differ across hosts. It also returns 409 if any account has a global privilege, GRANT OPTION, a role, a PROXY privilege, or a grant on a table, column, routine, name pattern, one of MariaDB's own databases or a database the customer does not own. It also returns 409 if two grants on the same host name the same database and differ in privileges, with the underscore escaped in only one grant. On a 409, the API lists every reason and makes no changes. To grant privileges on an unowned database, first adopt it with POST /databases/{name}/adopt.

As a command

Run as root on the server

Parameters

namepath ·DatabaseNameRequired

Request body

JSON· 1 field
userUsernameRequired
A username consists of lowercase letters, digits and underscores. For the user role, it also serves as the system account name.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X POST "$API/databases/users/alice/adopt" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "user": "alice"
  }'
Response · 201 Created
{
  "user": {
    "created_at": "2026-09-09T10:15:00Z",
    "grants": [
      {
        "database": "alice_shop",
        "level": "full",
        "privileges": "text"
      }
    ],
    "id": 1,
    "name": "alice",
    "other_hosts": [
      "text"
    ],
    "updated_at": "text",
    "user": "alice",
    "user_id": 2
  }
}

Errors

12 errors, each a status and a sentence
400--name is required
400A <what> name is 1 to 64 letters, digits or underscores
400A custom grant needs a privilege list of names separated by commas: SELECT, INSERT, ...
400A name beginning with <SIGNON_PREFIX> is the panel's own: its phpMyAdmin users
400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400The level is full, read-only or custom
400Username '<value>' is reserved
400user is required: the customer the database user is given to
401Authentication required
404MariaDB has no account named <name>
409<name> was not adopted:
409Database user <name> already exists

Change log

1 change since publication, newest first
0.2.371 Dec 2026
The operation now returns 409 for accounts with a role, a PROXY privilege, more than one authentication method, a grant on one of MariaDB's own databases, or two grants on the same host for the same database with different privileges.These accounts were previously eligible for adoption. The operation also returns 400 for root and mysql.
0.2.3630 Nov 2026
First published.
Generated from release 0.2.39 (current) · the API’s own descriptionThis entry last changed in release 0.2.37 on 1 Dec 2026.
urbestack.com/docs/api/post-databases-users-name-adopt/