Create a MySQL Database and add a user

At some point you will want to create and use MySQL databases for use in your web sites

 

You must first log into your cPanel hosting control panel - if you have lost or forgotten your username and/or password, you must email support and ask for the details (lost passwords will mean a password reset).

Once logged in, we will proceed with adding a database (please note that if you are installing any of the Fantastico Deluxe scripts, you will not need to manually add a database as each script automatically creates and configures them) ...

How to create a MySQL Database in cPanel video tutorial...





First, click on the MySQL Databases icon MySQL databases in the Databases section

First, you'll need to determine a name for your new MySQL database and enter that into the box named 'New Database:'. We recommend that use lower case letters, you can use letters and numbers for the name if you wish. Once enter, click on the 'Create Database' button next to that input box. A confirmation page detailing the database just created will follow, click the 'go back' link on that page to return to the MySQL Database section.

NOTE: The database name (which you will later use in your coding/scripts) takes the form of your-cpanel-username_database-name, for example (and following the video tutorial above) if your control panel username is mycpanel and the database name is number2, then the true database name for use in scripts/coding is gong to be mycpanel_number2. This allows you to connect and use the correct database in the MySQL database server.

Now you will want to create one or more users to use your MySQL databases. You have to have at least one user to write/read data to/from a database.

Scroll down a bit on the MySQL Database page in your cPanel, you will see a section titled 'MySQL Users' with a sub title 'Add New User' followed by three input boxes marked 'Username' 'Password' and 'Password (Again)'. This is quite self explanatory, so please enter the username and password you prefer, again we recommend lower case letters for the username, but there is also a maximum of 7 characters that you are allowed to enter for that username. Please follow the password guidelines (see right) when choosing a password to use for each user. You are asked to enter the password twice to prevent inaccurate typing and possible problems later when trying to connect to and using the MySQL database. Click the 'Create User' button and a confirmation page will follow detailing the username and password that you have just provided. Click the 'Go Back' link to return to the MySQL Databases page.

NOTE: The database user (which you will later use in your coding/scripts) takes the form of your-cpanel-username_database-username, for example (and following the video tutorial above) if your control panel username is mycpanel and the database username is second, then the true database username for use in scripts/coding is gong to be mycpanel_second. This allows you to connect and use the correct database in the MySQL database server.

Now that we have created the database and the user, we must add the user to the database and set the necessary privileges so that user can use the database.

Scroll down to the section titled 'Add User To Database'. There are drop down selection boxes called 'User:' and 'Database:'. In the first box (User), select the username that you just created and in the second box (Database) select the MySQL database that you created earlier. Now simply click the 'Submit' button. You will now see the 'Manage User Privileges' page. Select the privileges you wish to apply (it is usual to apply all privileges to at least one user of each database, this will allow all SQL functions to work for that user). Now click the 'Make Changes' button and a confirmation page showing the user and database.

The process is now complete.

  • 12469 Users Found This Useful
Was this answer helpful?

Related Articles

How to Create Custom Error Pages

This tutorial will teach how to create custom Error Pages. Create error pages for 404 Not Found...

MX Records

The purpose of this tutorial is to assist you in understanding what MX (mail exchange) records...

Using Index Manager

This tutorial will teach about using the Index Manager. The Index Manager allows you to customize...

Becoming Familiar And Navigating Around in CPanel

Lets learn about cPanel, and how to navigate it's many pages and functions. Making sure that your...

How to Change Your cPanel Password

This tutorial will teach you how to change your cPanel password. Please remember to make your...