These days, running a website means you’ll probably need to deal with databases sooner or later. Below, we'll show you how to access them and how to utilise them in your web application.
We'll presume you are already logged into your cPanel account, and if not - please see this guide on how to do so.
If you're on one of our shared hosting packages, you can use either localhost or the name of the server you're hosted on.
Search databases at the top of your cPanel home screen. This shows three options, we're mainly interested in the first and the last for now.
To setup a new database, click MySQL Database Wizard and follow the on screen instructions:
- Choose a name for your database
- Create a MySQL user account. Note: This user account is different to the account you use to log in to cPanel. It's created within MySQL itself and grants a user-definable set of permissions to the database you're creating.
- Add the user you created in Step 2 to the database you created in Step 1 and give it some permissions. We're not going to go through those now as that's outside of the scope of this article. For now we'll select everything, although it isn't advisable do this in a production environment. If you're unsure what you need to select here for a production environment, feel free to give us a shout and we'll be happy to help.
Once this is done, your database is setup & ready to use.
From here, you can either use PHPMyAdmin, accessible from cPanel to administer your database (see this guide for more information).
If you need to connect to this database using external tools or from an application hosted in another location, you'll need to allow that through the server's firewall:
- Find the Remote MySQL option
- Add the IP address of the remote host and a helpful comment to help you identify that host at a later date. If you're using tools on your local computer, this will most be the public facing IP of your network.
Note: You cannot use CIDR notation here, although you can use the % character as a wildcard (i.e. 192.168.%.%). If this opens up access to a wider address range than you need, you can use some more advanced Firewall rules to lock this back down to the exact range you want, although that's outside of the scope of this article.