How To Create A Database In CPanel

In my How To Make Your Own Website For Free series, I’d written a post for users of about creating a database and its associated user.

But I realized while reading a thread at the Bloggeries blog forum that I hadn’t really helped the majority of people who are not using So here’s a tutorial on creating a database using CPanel, which should hit the majority of people out there.

The database is where an application, such as WordPress, stores data. Most CPanel installations have one click installs for common applications that create the database for you, but they don’t have one click installs for every application you might want to use.

Getting Started

Once you’re logged into your hosting account, you’ll find a screen that looks similar to this one. If you use something other than CPanel, you’ll still have similar options available.

Main CPanel Screen

Click on the icon for MySQL databases, and you’ll see something like this:

MySQL Admin Screen

This single screen contains three different actions we’ll have to take. We’ll want to do them in the reverse order that they’re presented, so we’ll start by creating a user who will be able to access this database. I recommend creating a unique user for each database.

Creating The User

Go to the section of the screen that looks like this:

Add User Screen

Enter a user name and password and click the button next to the edit field. A user will be created with a name that is a combination of your CPanel user name and the name you entered. So if you entered “john”, and your CPanel user name is “jack”, the full name of the user is something like “jack_john”.

You will not need to remember this password for long, so make it fairly complex. And then before you click the button, copy and paste the password into Notepad to remember it. Also add to Notepad the full name of the user, which you’ll need when you setup your script.

Creating The Database

Now we’ll go to the section of the screen that looks like this:

Add Database Screen

Enter the name you want your database to use, and click the button. Keep it short, since generally the name will be truncated to 8 characters or so. The name of the database is also combined with your CPanel user name to create the full name of the database.

So if a CPanel user named “jack” created a database called “links”, the full database name might be “jack_links”.

Granting The User Permissions On The Database

Now we’ll go to the section of the screen that looks like this:

Set Permissions Screen

In the user drop down box, choose the user that you just created. In the db drop down box, choose the database you just created. Make sure the All check box is checked, then click Add User to DB.

This allows the user you created to actually work with the database you created.

Also, note that the names of the user and the database in the drop down box should be the full names. Note those for later use if you haven’t already.

Connecting To Your Script

So you’re doing all this because you have a script you want to use that requires a database. I can’t give much specific direction because I don’t know which script you’re using, but the basics are the same.

You will either edit a configuration file before you upload the script to your web host, or you will enter the information through a web interface after you have uploaded the script. Which way depends on the installation instructions for your script.

If you’re editing a configuration file, you’ll have spots where you need to put the database host, the database name, the database user, and the user’s password.

The database host should be localhost, unless you know that you have a good reason to have it be something different. The database name and database user should be the full versions of those names. The user’s password should be whatever you typed in when you created the user (copy and paste this from Notepad, don’t trust your memory).

This should get your script running and connected to the database. There might very well be more that you need to do after that to fully configure the script, but that’ll be script specific.

Leave a Reply