How to create and manage a MySQL Database in cPanel

From cPanel you cannot directly create or upload your database using PHPMyAdmin while making your website live. You need to follow some of the steps like – creating a database, user, etc.

The cPanel gives easy to use interface that makes easier to manage the database and make it available in the PHPMyAdmin.

In this tutorial, I am assuming that you already have a cPanel enabled web hosting server.

How to create and manage a MySQL Database in cPanel


Contents

  1. Create database
  2. Create user
  3. Assign user
  4. Upload tables
  5. Update Config
  6. Conclusion

 


 

1. Create database

  • Login to your cPanel account.

How to create and manage a MySQL Database in cPanel

  • Click on MySQL Databases under Databases section.

How to create and manage a MySQL Database in cPanel

  • Enter the name of the database and click on the Create Database button.

How to create and manage a MySQL Database in cPanel

  • The database is now created.

 

2. Create user

  • Navigate to Add New User section.
  • Enter the username and password. You can use Password Generator to create the strong password.

How to create and manage a MySQL Database in cPanel

 

  • Click on the Create User button.

 

3. Assign user

  • Navigate to Add User To Database.
  • Here, select your created user and Database from the drop-down.

How to create and manage a MySQL Database in cPanel

 

  • Click on the Add button.
  • You will be taken to the Manage User Privilege section. Here, check the All Privileges checkbox and click on Make Changes button.

How to create and manage a MySQL Database in cPanel

 


 

4. Upload tables

  • Back to cPanel Home and click on the phpMyAdmin under Databases section.

How to create and manage a MySQL Database in cPanel

  • Find your created database and import the tables or create a new one.

 

5. Update Config

Now update your database configuration in your project. Replace database, username, and password.

Example

<?php

$host = "localhost"; /* Host name */
$user = "webtechh_newuser"; /* User */
$password = "123456"; /* Password */
$dbname = "webtechh_newdatabase"; /* Database name */

$con = mysqli_connect($host, $user, $password,$dbname);
// Check connection
if (!$con) {
 die("Connection failed: " . mysqli_connect_error());
}

 

6. Conclusion

After creating the database require assigning a user for this you can either use the existing users or create a new one. You can change the user privileges on the database.

Make sure to update your project database configuration after creating and assigning the user to the database.

Related Post

Spread the love

Be First to Comment

Leave a Reply

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