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:

Was this article helpful?