/
How to Create a Database or Database User

How to Create a Database or Database User

Databases are key components in storing and transferring large amounts of content easily across the web.  From web applications, to product lists, managing web site additional feature functionality, and more; databases are becoming more and more common across the web.  Here is how you can create your own!

Procedure

  1. Login to your cPanel account.

  2. Scroll down your cPanel home page until you locate the 'Databases' section, and from there, select the 'MySQL Databases' icon.

 

image-20240710-215650.png

 

  1. The first section on the following page will be a gray box titled 'Create a New Database' enter the name you would like the database to have in the space provided, then select 'Create Database.'

 

image-20240710-215721.png

 

  1. Select the 'Go Back' button once the database shows as being created to return to the Database Creation page.  Scroll down to the section labeled 'MySQL Users' then fill in the spaces provided with the database username and password you wish to use, then select 'Create User' to complete the user creation.

NOTE: The Database username can be no longer than 7 characters.  The Password must be at least 5 characters in length and have a password strength of at lest 50 to be accepted.

image-20240710-215745.png

 

  1. Select the 'Go Back' button once the user has been created to return to the Database Creation page.  Scroll down to the bottom section to assign the Username to the Database.  Select the desired Username and Database from their respective dropdown menus then hit the 'Add' button.  This takes you to a permissions page were  you can assign permissions for the user.  Select the 'All Privileges' option, then select the 'Make Changes' button to complete the assigning process.

 

image-20240710-215828.png

 

  1. Once the user has permissions added, it is important to check to make sure the User was successfully assigned to the Database.    Select the 'Go Back' button and return to the Database Creation screen.  From there, scroll down until you see a section labeled 'Current Databases.'  Make sure your Username is listed under the 'Privileged Users' column.

if you don't want to issue full privileges to a user, below are definitions of each individual permission that you can choose which to give a user.

  • Alter - Enables the user to change the structure of database tables.  Is also required to rename, add, or drop tables.

  • Alter Routine - Needed to add or drop stored routines (procedures and functions.)

  • Create - Enables the creation of new Databases and Tables.

  • Create Routine - Needed to create or destroy routines (procedures and functions.)

  • Create Temporary Tables - Enables the creation of temporary tables.

  • Create View - Allows the user to create view, or replace and existing view.

  • Delete - Allows rows to be deleted from a database.

  • Drop - Allows you to remove existing databases, tables, and views.

  • Event - Lets the user create, drop, view, or alter events from the Event Scheduler.

  • Execute - Required to execute stored routines (procedures and functions.)

  • Index - Lets the user create or drop indexes. This applies to existing tables only.

  • Insert - Allows rows to be inserted into database tables.

  • Lock Tables - Enables the use of the Lock Tables statement to lock tables that have the 'Select' privilege.

  • References - Unused with current MySQL version.

  • Select - Enables the user to select rows from tables of a database.  Also needed for other statements that read common values.

  • Show View - Enables  use of show create view.

  • Trigger - Enables Trigger operations.  Needed for a table to create, drop, or execute triggers for that table.

  • Update - Enables rows to be updated in tables in a database.

NOTE: If you don't see your username in that section next to your database, it has NOT been assigned and will not connect successfully!  You will need to repeat step 5 above to make sure it is assigned.

image-20240710-215936.png

 

Related content