Zomro » FAQ » Hosting: Creating databases by api in Cpanel
flag We stand with Ukraine. To make an impact, please consider donating.

Hosting: Creating databases by api in Cpanel


Adding databases and users is not very convenient to perform from the control panel, especially with a large number. This can be simplified using the api.
At the time of this writing, to console has access at all tariffs except "AFFORDABLE".
You can connect to the hosting to execute commands using the "Security - SSH Access" key or from the "Advanced - Terminal" web interface itself.

Create database:
uapi Mysql create_database name="userprefix_DBname"
Create a user and specify a password for it:
uapi Mysql create_user name="userprefix_DBuser" password="yourpassword"
Adding a database to a user:
uapi Mysql set_privileges_on_database user="userprefix_DBuser" database="userprefix_DBname" privileges=ALL PRIVILEGES
You need to change the data to yours:
userprefix - user prefix (your login)
DBname - database name
DBuser - username to connect
yourpassword - the password for the new mysql user

When using a simple password, you may get an error:
This system does not allow the given password for “MySQL Users” because it is too weak and would be too easy to crack. Please select a password with strength rating of 65 or higher.

Run the command again specifying a more strong password.