How to create database, database username and grant all rights on cPanel server via command line using UAPI

You can create a database, database user, and grant privileges using the cPanel User API (UAPI) command line interface.

Connect to your cPanel account using SSH.

Type the following command to create a new database:

uapi --user='cpanel_username' Mysql create_database name='database_name'

Replace ‘cpanel_username‘ with your cPanel account username and ‘database_name‘ with the name of the database you want to create.

Type the following command to create a new database user and set the password:

uapi --user='cpanel_username' Mysql create_user name=username password='password'

Replace ‘cpanel_username‘ with your cPanel account username, ‘username‘ with the username you want to use, and ‘password’ with the password you want to set.

Type the following command to add the user to the database and grant all privileges:

uapi --user='cpanel_username' Mysql set_privileges_on_database user='username' database='database_name' privileges='ALL PRIVILEGES'

Replace ‘cpanel_username‘, ‘username‘, and ‘database_name‘ with your cPanel account username, the username you just created, and the name of the database you just created, respectively.

Done! You have now created a database, a database username, and granted all rights to the username for the database using the cPanel UAPI command line interface.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *