How to create a database in cpanel, how to create database in phpmyadmin in cpanel, how to connect database in cpanel,  cpanel database, database in cpanel,

How to create a database in cpanel

Having gone through the factors and steps to consider before hosting your website and also how to host your website in our previous articles we were able to do up to the point of uploading your website files but we were not able to cover how to create a database in Cpanel and connect it with your website files. What we know, by default unless a website is an informational website that has static content that does not require update from time to time, the largest percentage of websites require a database.

In this article, we shall describe the steps followed while creating a database in Cpanel and connect it with the website files. Cpanel provides a section that allows you either to upload an existing database or create a new one from scratch. A database is a tool or engine used in system development that acts as the central place where data is stored.

To begin;

  • Login to your Cpanel
  • Once you have logged in, navigate to the database section and click on MySQL databases

How to create a database in cpanel

  • Once in the database section, you will find it has various sections which include
  1. Create New Database
  2. Modify Databases
  3. Current Databases
  4. Add New User
  5. Add User To Database
  6. Current Users
  • In the Create New Database section, you define your database name. The database name is determined by you either by the website name or from the name of your choice

Fill in the name of your database and click create database

You will note that the username you used during login will be added to your database name, therefore the name of your database name will be yourusername_yourdatabasename

You will receive a success message, click go back

How to create a database in cpanel

  • In the Modify Databases section, it has two sections

Section one is check database where you can check whether your database has an error, you can do this by clicking the check database button

Section two involves repairing the database where if the above section produced errors, you can click the repair database to fix the errors.

  • In the Current Databases section, the databases that you have created are shown in this section. One thing with hosting providers, depending on the hosting you have purchased you are allowed to create from one database to an infinite number of databases.
  • In the MySQL users section, this is where you will configure the users who want to give privileges of accessing your database. A database is not complete without defining who has access to it. To do this you need to add a user where you will assign a username and a password that are specific to a database.

How to create a database in cpanel

  • In the add users section, Fill in the username, and just like we highlighted while creating a database name the login username is added to your database username. Create a distinct and strong password that no one can guess. If your passwords are not strong, you can use the password generator tool to create a strong password which you should note somewhere. Click create user button to save the user.
  • Next, you will need to connect the user you have created above with the database you created. This is done by adding user to the database.

Select your user and also your database and click add.

How to create a database in cpanel

  • Next, you will be directed to a screen with some privileges.

If you want this user to have 100% access to your database, you will need to check all privileges to grant the user all-access, if not, you will check the privileges you want to grant the user.

How to create a database in cpanel

Click Make changes to save changes.

Click go back.


Having followed the above steps, we have completed the process of creating a database in Cpanel.

Next, to view the database and create tables or upload an existing table, you will need to go back to the home page of cpanel by clicking the Cpanel icon on the top left

Head to the database section and click PHPMyAdmin

The list of databases present will be available

How to create a database in cpanel

Click on your database and head over to either creating your tables or uploading your existing database.

To define the connection to the database you have created in php, you will need to do as shown below

$server="localhost"; //localhost is the default server name used
$username="loginusername_username"; //the username we created
$password="thepasswordxxx "; //the database password
$databasename="loginusername_databasename"; //database name
$con=mysqli_connect($server, $username , $password, $databasename) or die("error");