How to Set Up a MySQL Database in Cpanel (for Script Installations)

If you run across a PHP/MySQL-driven script that you want to install, you’ll need to know how to set up a MySQL database. In this tutorial, I take you step by step through the process. Please note that this tutorial assumes that you use Cpanel to access the functions necessary to set up a MySQL database.

Without further ado…

1) Navigate to the Databases section in Cpanel. It will look something like this:

The first icon, ‘MySQL Databases’ is the one that you want to click!

2) On the page that comes up, you’ll want to navigate to the area labeled ‘Create a New Database.’ It’ll look something like this:

Pick a database name that you’ll recognize later. You may come back to this database years from now and you don’t want to be left scratching your head as to what script the database goes to!

Note: I’ve sanitized the pictures used in this tutorial so that they’re not giving away sensitive account information. So, in your case, instead of seeing a ‘l_’ prefix, you’ll likely see your account username before the underscore.

3) After clicking ‘Create Database’, you’ll see this screen:

Click ‘Go Back’ to continue.

4) So, so far, we’ve set up our database. We’re not done, though. We need to create a user that can access the database and give that user rights to access/modify it. To that purpose, we scroll down to the ‘MySQL Users’ section where it says ‘Add a New Uswer.’ That’ll look like this:

Create a username and a strong password.

For your password, include lowercase & uppercase letters, make the password at least several characters long, and it sure doesn’t hurt to use a special character like ‘!’ in it. (There are websites out there that’ll help you generate a strong password.) Make sure to record the database name you made earlier, this username, and the password you just made in a safe location for future reference. Once finished, click ‘Create a User.’

5) Similar to prior steps, doing so brings up this page:

Click ‘Go Back’ to continue.

6) Now we want to assign the user we just made to the database we made. To do so, navigate to the section on the Databases page labeled ‘Add a User to a Database’. It’ll look something like this:

Find the User you just made and then the Database you made earlier. Select those respectively from the two dropdowns. Finally, click ‘Add.’

7) After clicking ‘Add’, the following page shows up:

Check ‘All Privileges’ and click ‘Make Changes’.

That’s it. You now have a MySQL database set up! You’ll need to propagate it with tables and data but most scripts either provide you with an installation page that does it for you or an SQL schema you can run to populate your database with what it needs to run. I’ll cover manually running SQL schemas in PHPMyAdmin in the future. Hope this helped!

If you found this post useful, leave a comment below!

Leave a Reply

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