Knowledge Base

How to Create a MySQL Database and User in cPanel

How to Create a MySQL Database and User in cPanel

Many websites and applications need a MySQL database to store information. WordPress, for example, uses a database to store posts, pages, users, settings and other website data.

If you need to create a new database manually on your Cheap Host cPanel account, you can do this using the MySQL Databases section in cPanel.

Create a New MySQL Database

  1. Log in to your Cheap Host cPanel account.

  2. Go to the Databases section.

  3. Click MySQL Databases.

  4. Under Create New Database, enter a name for your database.

  5. Click Create Database.

cPanel normally adds your account username as a prefix to the database name.

For example, if your cPanel username is:

example

and you create a database called:

wordpress

the full database name may become:

example_wordpress

Make a note of the full database name, as you may need it when configuring your website or application.

Create a Database User

The next step is to create a MySQL user that can access the database.

Scroll down to the MySQL Users section.

  1. Enter a username for the new database user.
  2. Enter a strong password.
  3. Enter the password again to confirm it.
  4. Click Create User.

You can also use cPanel's password generator to create a strong random password.

Make sure you save the username and password somewhere secure if you will need to enter them into an application later.

Add the User to the Database

Creating a database and creating a user are separate steps.

You must also give the user permission to access the database.

Under Add User To Database:

  1. Select the MySQL user you created.
  2. Select the database you created.
  3. Click Add.

You will then be asked which permissions the user should have.

For most website applications, including WordPress, select:

ALL PRIVILEGES

Then click Make Changes.

The user should now have permission to access and modify the database.

What Details Will I Need?

When installing an application manually, you will usually need the following information:

  • Database name
  • Database username
  • Database password
  • Database host

On most Cheap Host cPanel accounts, the database host will normally be:

localhost

Your software may refer to these as MySQL credentials or database connection details.

Where Are Database Details Stored in WordPress?

If you are configuring WordPress manually, its database settings are stored in:

wp-config.php

This file contains values such as:

DB_NAME

DB_USER

DB_PASSWORD

DB_HOST

Take care when editing this file, as incorrect details can prevent WordPress from connecting to its database.

Common Database Connection Problems

If your website reports an error such as:

Error establishing a database connection

check the following:

  • The database name is correct.
  • The database username is correct.
  • The password is correct.
  • The user has been added to the database.
  • The user has the required permissions.
  • The database host is set correctly.

A surprisingly common issue is creating both the database and user but forgetting to add the user to the database.

Important

Deleting a MySQL database can permanently remove website data, so always make sure you have a backup before deleting or replacing an existing database.

If you are unsure which database belongs to your website, please contact Cheap Host support before making changes.

Please rate this article to help us improve our Knowledge Base.

0 0