How to create a MySQL database and users
This guide explains how to create MySQL databases in cPanel, create database users with permissions and assign them to databases.
You'll need to be logged in to cPanel to complete these steps.
Manage Databases (Create, Check, Repair, Rename, Delete) & Users
- Within the Databases section of cPanel click MySQL Databases.
- At the top of the MySQL Databases screen you'll see options to Create a New Database, Modify a Database and Current Databases.
- Create New Database
Every database you create will have a pre-fix of your account name - in this case you can see that is staffte6 - so the full database name will be:
[cPanel username]_[database] e.g. staffte6_my-new-database
Type your desired database name in the New Database field and click Create Database. - Modify Databases (Check or Repair)
There are options here to Check Database or Repair Database - select the database you'd like to work with from the respective drop-down. - Current Databases (Change a Users Permissions, Remove a User, Rename Database, Delete Database)
Here you can see existing databases.
You can Change a Privileged Users assigned permissions by clicking on their Username.
You can Remove a Privileged User (a user with database access) by clicking the dustbin next to their name. Note: This only removes the users access from this database, it does not delete the user.
You can Rename the database by clicking Rename. Note - you can only rename the database suffix - you can't change the prefix.
You can Delete a database by clicking Delete. Note - this will only remove the database - it will not delete any privileged users that have access.
- Create New Database
- In the next section of the screen - MySQL Users - you can add a new database user.Type the name of the new database user in the Username field. As with the database naming above, all users will have a prefix of your cPanel account name.
[cPanel username]_[username] e.g. staffte6_my-new-dbuser
Enter a secure password - in both the Password and Password (Again) fields. cPanel provides a Password Generator to create secure passwords for you.
Please make sure you note down this password - you will need it to setup any application that will be accessing this database using this user account.
Click Create User to complete the process. - In the final section you can give a user access to a database and assign the permissions that user has.
Note: Users can be assigned to multiple databases, and have different permission assigned for each.
Missing this step can result in an Access Denied message - even though you've created a database, and created a user - you must complete this step to grant that user appropriate access to the database.Select the appropriate User and Database from the drop-downs and click Add.You'll then see the Manage User Privileges screen, where you can assign database permissions to the user. Most likely you will want to select All Permissions.
Some applications may state what permissions are required, for example, a user accessing a WHMCS database would need DELETE, INSERT, SELECT, UPDATE, LOCK TABLES permissions for day-to-day use and additionally during installation, upgrade, activating & deactivating modules ALTER, CREATE, DROP & INDEX.
Once you've selected the required permissions click Make Changes. - In the Current Users section you have options to Change a Users Password, Rename a User or Delete a UsersNote: Deleting a user will remove that user from the system and therefore remove it's access to any databases for which it was a privileged user.
If you are installing a web application, then you will be asked for your database name, database username and password. You will also be asked for the MySQL or Database hostname - this will always be simply localhost.