Hey everyone! It is Josh here with HostGator. Today I’m going to show you how to create a brand new MySQL database and user in cPanel. Let’s dive in.
Now if you’re just installing software or a new CMS, nine times out of ten the database and database user are going to be created for you. So if you’re using Softaculous and installing WordPress or Joomla, there’s a good chance this is already done for you, but sometimes you just might need to do it manually.
I’m gonna show you how to do that today. We’ll start out here in our cPanel, and I’m gonna scroll down until I see ‘MySQL Databases‘ This is going to allow us to create a brand new database and a brand new user, and actually, add that user to the database so that it can access it.
Create MySQL Database From cPanel
You’ll see here in the ‘Create a new Database‘ section. We’re just going to type in the name. Notice here that your cPanel username is actually prefixed to this database name so all you have to do is type in really what you want to name the database.
I’m going to name mine ‘fahimdb‘, and I’m going to click ‘Create Database‘. You can see we’ve got a successful message here. “Added the new Database‘. I’m going to click ‘Go Back‘ and scroll down just a little bit to see all the databases that I have in the cPanel.
You can see here fahimdb is my new database that’s created. What I want to do is actually create a user that can access this database. Every single database needs to have a user that can access it and grant it a certain level of permissions so that it can go through different processes.
Create MySQL User From cPanel
What I’m going to do is scroll down to MySQL users and I’m going to create one of the exact same names to add to that database. I’m going to create ‘fahimdb‘ as my user. It’s going to ask you for a password. I love using the password generator here from cPanel.
It’s going to create a very secure password. I’m going to go ahead and copy that password over into a paste bin or a text file over here. Click ‘I have copied this password in a safe place‘, and click ‘Use Password‘. It’s already got a very strong password set for you there.
It’s going to be really easy to use. What I want to do is click ‘Create User‘. Now that a brand new user is created, so I’m going to click ‘Go Back’ one more time. Now what I want to do is probably the most important part, so stick around for this. What I want to do is actually add that user to the database so they can access it.
Add Database & User With Privileges
We’re going to scroll all the way down to the bottom here where it says, ‘Add Users to Database‘. I’m going to select that user which is fahimdb, and I’m going to select the database that needs to be used for my dropdown. So bpitt_fahimdb is both the user and the database here.
I’m going to click ‘Add‘. It’s going to ask me what level of privileges or permissions I want to add to this user on that database. I’m going to default to all privileges. You know you can hand-select them here if you want to. 9 times out of 10 though all privileges are going to be the best way to go.
Once we’ve selected all privileges, click ‘Make Changes‘ It’s going to give me that successful message again. I’m going to click go back one more time, and now I can see if I scroll down here just a little bit, I’ve got my database and I’ve got my privileged user here. It’s already accessible.
It’s gonna be really easy to use and as long as I have that password set. Now that user can actively access that database and create new data. And that’s it I hope you all found this helpful. If you have any questions or comments, please leave them below and bookmark us if you want to see more.