How to Manage MySQL Databases and Users on cPanel

How to Manage MySQL Databases and Users on cPanel

You can use MySQL to run dynamic websites on your web hosting account. Most automatic script installers (e.g. softaculous) install the software together with the required MySQL databases and users.

However, in some cases, you might need to create a custom MySQL database and associate a username with it especially if you are running tailor-made web applications.

Creating a MySQL database and a user very straightforward from cPanel and we are going to show you how to do this in this article.

Special note: consult HostAdvice’s Best MySQL hosting  page to find the leading web hosts in this category, including expert and user reviews.

Prerequisites

  • A domain name e.g. www.example.com
  • A web hosting account that supports cPanel
  • cPanel username and password.

Step 1: Log to your cPanel Account

The first thing is to log in to your hosting account by visiting your cPanel URL (e.g. ‘http://www.example.com/cPanel’).

Replace ‘www.example.com’ with the primary domain name associated with your hosting account and you will be taken to a login page as shown below. Enter your username and password and click on ‘Log in’

Step 2: Locate the MySQL® Databases tool

Type the word ‘database’ in the search box and click on the ‘MySQL® Databases’ icon as shown in the image below:

Step 3: Create a database

Next, create a database on the next screen by entering your desired database name. Then, click on the ‘Create Database’ button. Refer to the image below:

Your database will be created with a prefix if you are on a shared hosting. This assists in associating the databases to your account. Once you are through click on the ‘Go Back’ link to explore your databases as shown below:

You can now find your MySQL database under list of databases on your cPanel account

As you can see in the above image, our database does not have a privileged user yet. We need to create a user and assign the same to our database.

Step 4: Creating a database user

We are now going to create a new user for our MySQL database. Scroll down until you see ‘MySQL Users’. Enter your desired username and password. Please refer to the image below:

Just like the database, the username will be prefixed with the username associated with your hosting account. When you have verified the details, click on, ‘Create User’ as shown above.

Your user will be created successfully, click the Back button to go back to the users list

Step 5: Assign user to the database

We now have a database and a username. However, we haven’t linked the two yet. If any script or software tries to use the details to access the database, an error will be raised (e.g. ‘Access denied for user ‘test’@’localhost’ (using password: YES)’)

So once we are back to the ‘MySQL® Databases’ screen, we need to navigate to the heading, ‘Add User To Database’

Then we need to select the MySQL database that we create above and the associated user and click on the add button as shown below.

Your username is now associated and linked to the database.

Conclusion

That is all when it comes to creating a MySQL database and the associated user on cPanel. You can create as many databases and users depending on your software or website needs.

You should use strong passwords to keep your websites away from hackers especially if you will be accessing your database from phpMyAdmin (the graphical user interface for MySQL). We hope this resource will assist you to manage your MySQL databases and users on your cPanel account.

 

Check out the top 3 MySQL hosting services:

Kamatera
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
FastComet
$1.79 /mo
Starting price
Visit FastComet
Rating based on expert review
  • User Friendly
    4.7
  • Support
    5.0
  • Features
    4.8
  • Reliability
    4.5
  • Pricing
    5.0
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Backup and Restore MySQL from cPanel

This article teaches you how to backup and restore a MySQL database from within
2 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Optimize Queries in your MySQL and MariaDB Databases

In this guide, we cover what a database administrator can do to optimize databa
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Move Your WordPress Site from Your Local Web Server to Your Live Site

You can always accelerate the development process by developing your WordPress s
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Disable MySQL 5 "Strict Mode" on an Ubuntu 18.04 VPS or Dedicated Server

How to Disable MySQL Strict Mode on MySQL 5.6 Running on an Ubuntu 18.04 VPS.
2 min read
Idan Cohen
Idan Cohen
Marketing Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top