InMotion Hosting Support Center

If you are running cPanel on your server, then you should use the cPanel API to create the database from the command line. Creating the database this way, allows for cPanel to integrate the necessary permissions for each cPanel user to access the databases they are granted access to. For instance, if you create a database from the command line using MySQL, the database will not appear in the cPanel interface or phpMyAdmin. In this guide, you can learn the commands to create a MySQL database, database user and password, as well as, assign all privileges to the user for the database.

Create a Database Using cPanel API

  1. Log into your server via SSH.

  2. Run the following command to create the database:

    uapi --user=exampl3 Mysql create_database name=db_name

    NOTE: Be sure to replace exampl3 with your actual cPanel username and db_name with the actual name you would like to give to the database.

  3. Run the following command to create the database user:

    uapi --user=exampl3 Mysql create_user name=db_user password=P@s$w0rd123!

    NOTE: Be sure to replace exampl3 with your actual cPanel username, db_user with the actual name you would like to give to the database user, and P@s$w0rd123! to the actual password you would like to assign to this user.

  4. Assign the database user privileges to access the database by running the following command:

    uapi --user=exampl3 Mysql set_privileges_on_database user=db_user database=db_name privileges=ALL

    NOTE: Be sure to replace exampl3 with your actual cPanel username, db_user with your actual database user, and db_name with the actual name of the database.

cPanel MySQL® Database Wizard

The cPanel MySQL® Database Wizard creates a database, as well as a database user and password. The Wizard also completes the process of assigning privileges to the database user (to use the database as needed). For step-by-step instructions you can refer to our guide: How to Create a MySQL Database in cPanel.

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!