A mySQL database is the world’s most popular relational database today. The mySQL community edition is open source and is used freely in millions of web hosts. It is an easy to use database system and has been proven to be very stable and reliable. It is the most frequently used database in web hosts and is part of the LAMP stack which stands for Linux, Apache, mySQL, PHP. These are the four components that most web hosts run today.
Note that Apache is the web server. In reality, today, most hosts run some kind of web server, not necessarily Apache. This is because there are other web servers that are lighter and are optimized for running in shared hosting environments, cush as the LiteSpeed web server.
To use mySQL, you run the mySQL server. To do this, you can download the server from the official mySQL website (https://www.mysql.com/downloads/). Then, you can install the mySQL server component on your server. But if you have a web hosting account, there is no need for this. As mentioned above, most hosts have already installed a mySQL server and provide it to you so you can use it for your hosting needs.
Since a mySQL server is provided in most hosts, there should be a way for the hosting account user to manage mySQL i.e. create databases and connect them to scripts. cPanel provides a group of mySQL management utilities to enable users to manage this important part of the web hosting account, the mySQL database.
These utilities make it very easy for a user to manage mySQL without the need of highly specialized technical configuration.
When working with a hosting account, mySQL databases are needed for connecting them to scripts.
A script is a software running on your web hosting account. Examples are Wordpress, Joomla, Drupal (i.e. CMS systems), Blog systems, eShops (PrestaShop, Woocommerce), Forums, Social scripts and of course any web based application you develop as a Developer which would need a database to work.
When you purchase a script, if it requires a mySQL database to work, then you would have to create the database from cPanel. Usually the script has instructions on how to connect the database, but you should be able to at least create the database.
Click on the mySQL databases icon in cPanel, in the databases group.
Create the Database
In the “Create new Database” field, type a name for your database. Your database name will be prefixed by another name by the system. In this case, it is the website name “trainingwebpanel”. You cannot modify this name.
Click on the Create Database button.
A new database is created. You can see it in the list of Current Databases now. In our example, it is called testdb, but the full database name contains the prefix, so it is trainingwebpanel_testdb.
Create a user
Your script will connect to the database by means of a User. You need to create this user.
In the Add New User section, enter a username and password for the database user. Click on Create User.
A new user is created. You can see the new user in the Current Users list.
Associate the user to the DB
Now, you need to associate the user to the database you created. This means that this user will have access to this particular database.
In the Add User to Database section, select your user in the first drop-down list box. Select your database name in the second drop-down list box. Click Add to add this user to your database.
Create the user privileges
Every user in a mySQL database should have privileges defined. These privileges control what kind of access this user has to the database.
In most cases you would have to provide this user with full database read and write privileges, unless the script instructions specify something different.
As soon as you click on the Add button on the previous step, a new page appears, with the title Manage User Privileges. Here, you need to define the privileges for this user. For most cases, you can provide all privileges, except if the instructions of your script guide you to select a specific set of privileges.
Click on the All Privileges check box to select all the available privileges. Your user now has full access to the database.
Click on Make Changes.
In the Current Databases list you can now see that this user appears next to the database. Your database is now ready to use.
All scripts have some instructions on how to integrate them with the database. Usually the way to do it is to access a configuration file in the script folders. It is usually a text file which contains information like this:
Database server: [your mySQL server IP address or domain name]
Database name: [your mySQL database name]
Database user: [your mySQL database user]
Database password: [your mySQL database password]
In some other cases, you would have to configure a php script which would have placeholders for the above information.
Another way some scripts connect to the database is by providing you with an installation wizard which will prompt you for the above information.
After creating the database and connecting it to your script, you do not really have to do anything with the database such as manage it or create tables and fields. The script will connect to the database and create all necessary tables, fields and any other database elements needed.
Hope you found this useful!
Check out our other article on Web Hosting Accounts.