How To Create A Database In cPanel?
If you are working on a website or web application, you will always want a database. If you use cPanel, which is common for hosting providers, you will see how easy it is to create a MySQL database! Whether you’re creating your first WordPress website, an eCommerce store, or a custom PHP app, this article will take you through how to create and manage a database on cPanel from start to finish.
Let’s dive in!
Step 1: Log in to Your cPanel Account
Start by logging into your cPanel. Often, you’ll be able to find it by going to:
yourdomain.com/cpanel
Enter the username and password provided by your web hosting provider.
Step 2: Go to the “MySQL® Databases” Section
Once in cPanel, scroll down to the databases section. You’ll want to select the MySQL® Databases icon.
This is where the fun begins!
Step 3: Create a New Database
Under Create New Database, simply type in a name for your database. Keep it short and relevant (for example, myblog_db or store123).
Then click Create Database.
You’ll get a confirmation message saying your database has been created successfully.
Step 4: Create a Database User
Now that we have created the database, let’s set up a user who can access the database!
Scroll down to the MySQL Users section. Under Add New User, do the following:
- Choose a username (e.g., user123)
- Enter a strong password (you can use the Password Generator for extra security)
Click Create User.
Step 5: Assign User to Database
Next, we need to connect the user with the database.
Go to Add User to Database:
- Select the user you just created
- Select the database you just made
- Click Add
On the next screen, you’ll be asked to assign privileges. For full access, check All Privileges and then hit Make Changes.
Step 6: You’re All Set!
Your database is now ready to use! You can view it under Current Databases in the same panel.
Whenever you need to connect your website or app to this database, you’ll use these credentials:
- Database Name: e.g., cpaneluser_myblogdb
- Database Username: e.g., cpaneluser_user123
- Password: the one you set
- Host: usually localhost
Bonus Tips
- Use the MySQL Database Wizard: Some cPanel setups offer this for an even simpler experience. It combines all the steps above into one easy flow.
- Back Up Your Database Regularly: Use the cPanel backup tool or phpMyAdmin to export the database.
- Use phpMyAdmin for Management: You can use phpMyAdmin to see, edit and manage your data visually.
- Delete Unused Databases/Users: Removing old databases and users keeps your setup clean.
Final Thoughts
Creating a database in cPanel is straightforward, and it’s a skill worth having if you’re managing any kind of dynamic website. Now that you know how to do it, you can confidently move forward with installing your CMS, building your app, or even running SQL queries directly.
Need help with connecting your database to WordPress or a custom app? Contact Cantech today!
Frequently Asked Questions (FAQs)
Should I create a new database for every website?
It is best practice to create separate databases for every website or application you have so your data is organized and secure.
What is the default hostname for MySQL in cPanel?
The default hostname typically is localhost unless your hosting provider tells you otherwise.
Can I use the same user for multiple databases?
Absolutely yes, just assign the correct privileges to each database.
How do I access phpMyAdmin in cPanel?
In cPanel, you can scroll to the Databases section and click on phpMyAdmin.
Is it safe to use the Password Generator in cPanel?
Absolutely! The Password Generator generates a strong and secure password, better than anything you could create yourself!
Can I delete a database in cPanel?
Yes. Just scroll down to Current Databases, locate the database you wish to delete, and then click on Delete the database. Note: this is not reversible!
What is the difference between the MySQL Databases tool and the MySQL Database Wizard?
The MySQL Database Wizard has combined all of those steps (create a database, create user, and assign permissions) into a single easy flow. This is a great option for new cPanel users.
Do I need to restart anything when creating a database?
No! The database is immediately ready to use once you have created it and assigned the user permissions.