How to create MySQL databases and users Print

  • 29

This article will show you how to create a MySQL database and database user in your Krystal cPanel account. This article assumes that you are already successfully logged into cPanel.

Step 1

In cPanel, click on the MySQL Databases icon in the Databases section.

Step 2 - Create a database

In the top half of the screen you will find the Create New Database and Current Databases sections.

In the Create New Database section type in the name of your new database. In the example below, we have chosen the name myshop. Click the Create Database button to create your new database.

The new database will be created. Click the Go Back button to return to the MySQL Databases page. The database will be named as follows:

 

[cPanel username]_[database]

Step 3 - Creating a database user

Before you can access your database, you must set up a dedicated MySQL user. This user is distinct and separate from your cPanel username. Looking towards the bottom of the MySQL Databases screen you will find the MySQL Users area. Here you can create MySQL users and assign them to databases. A single MySQL user may be assigned to multiple databases and multiple MySQL users may be assigned to a single MySQL database. It is quite flexible. However, in most cases, you will simply want a single user per database.

To create a MySQL user,

  1. enter the username in the Username: box as shown. The username has a maximum of 7 characters.
  2. enter a secure password or use the Password Generator function.
  3. click the Create User button.

The new user will be created. Click the Go Back button to return to the MySQL Databases page. The user will be named as follows:

 

[cPanel username]_[MySQL username]

Step 4 - Adding a user to a database

The final step is to assign the user to a database and grant the required privileges.

  1. select the MySQL user from the User: drop down control.
  2. select the MySQL Database from the Database: drop down control.
  3. click the Add button.

Now we must assign the correct privileges. In almost all cases you will want to grant ALL PRIVILEGES to the user for the database concerned. To do this, simply click on the ALL PRIVILEGEScheck box. Then click the Make Changes button.

You will then receive a brief confirmation that the settings have been changed. Your database and database user are now ready for use.

If you are installing a web application, then you will be asked for your database name, database username and password. You will also be asked for the MySQL or Database hostname - this will always be simply localhost.


Was this answer helpful?

« Back