1. Home
  2. Docs
  3. Developer Guide
  4. API
  5. MySQL Databases and Users

MySQL Databases and Users

Two functions manage MySQL/MariaDB: databasemysql for databases and usermysql for database users. Names are always prefixed with the account username and an underscore (john_shop).

Databases (databasemysql)

URL: https://YOUR-SERVER:2304/v1/databasemysql/ — permission MySQL Databases.

Create

Send the name without the prefix in database:

curl -k -X POST https://203.0.113.10:2304/v1/databasemysql/ -d "key=YOUR_API_KEY&action=add&user=john&database=shop"
{"status":"OK","msj":"Mysql database successfully created","dbsPack":"6/0"}

The database is created as john_shop. dbsPack shows the package limit and the previous count.

List

curl -k -X POST https://203.0.113.10:2304/v1/databasemysql/ -d "key=YOUR_API_KEY&action=list&user=john"
{"status":"OK","msj":[{"database":"john_shop","user":"","host":""}]}

Delete

Send the full name:

curl -k -X POST https://203.0.113.10:2304/v1/databasemysql/ -d "key=YOUR_API_KEY&action=del&user=john&database=john_shop"
{"status":"OK","msj":"Deleted john_shop database"}

susp / unsp temporarily block and restore access to a database.

Database users (usermysql)

URL: https://YOUR-SERVER:2304/v1/usermysql/ — permission MySQL Users.

Create a user and grant access

ParameterDescription
userHosting account username
userdbUser name without the prefix, for example shop
passPassword
dbaseFull database name to grant access to, for example john_shop
hostlocalhost for websites on the server, % for any host, or an IP address
curl -k -X POST https://203.0.113.10:2304/v1/usermysql/ \
  -d "key=YOUR_API_KEY&action=add&user=john&userdb=shop&pass=S3cretPass&dbase=john_shop&host=localhost"
{"status":"OK","msj":{"database":"john_shop","userdb":"john_shop","host":"localhost","pass":"S3cretPass"}}

List

curl -k -X POST https://203.0.113.10:2304/v1/usermysql/ -d "key=YOUR_API_KEY&action=list&user=john"
{"status":"OK","msj":{"1":{"user":"john_shop","host":"localhost"}}}

Delete

curl -k -X POST https://203.0.113.10:2304/v1/usermysql/ -d "key=YOUR_API_KEY&action=del&user=john&userdb=john_shop&host=localhost"
{"status":"OK","msj":"Deleted john_shop User"}

action=udp changes a user’s password (userdb, host, pass).

Related

Was this article helpful to you? No Yes