Computer Programming web Web programming Tips



Web Hosting CPanel and MySQL setup

By Sergey Skudaev


In this tutorial I will explain how to create MySQL databases and users in the web hosting control panel (CPanel). If you create website for small business then you will need a database to store records about your customer or products. MySql is a good choice if your number of records not exceed 100000. If it is greater the 1000000 then you will need an Oracle database. For small business MySQL database usually is enough and most hosting providers have it.

When you buy hosting, the hosting company sends you a welcome email with all required logins and passwords to access the control panel. Login to the control panel and scroll down untill you see the MySQL databases icon.

Hover mouse over a thumbnail to see a large image.

MySQL database icon in cpanel

Click the MySQL database icon on the left. Create New Database window will be displayed.

Create New MySQL database

In the new database text box type your database name 'mydb' and click the Create Database button. A new MySQL database will be created. The database name should be short because system adds your control panel login in from of it. For example, if you enter db for database name, the actual database name will be your <login>_db.

Create New MySQL database

Click the Back link to return to the previous screen. If you changed your mind, you can delete your db. Just click the Delete database link and it will be deleted.

Modify database

Scroll down to see text boxes for user and its passwords. I always create two users an admin user with full access to database and a regular user with limited permissions.

Let us create admin user. Enter 'admin' in the username field and 'Spring9$' in the password field. For password you have to use mix of Capital, small letters, numbers and special characters.

Add user to database

Enter password in the second password field and click the Create User button. User will be created. Click back link to return to the previous screen. User is displayed and you can delete it if you want to.

Now you have to add user to the database. Since, you have only one database and one user they are selected by default. If you had few users and few database, then you would selected desired database and user. Click Add button. MySQL Account Maintenance window will be displayed. Mark the All Privilegies check box to give admin user full access to the database.

Full access to database

Click the Make Changes button to save changes. User will be added to database. Click the Back link to return to the previous screen. Create one more user. The regular one with limited access.

Enter 'reg' for username and enter 'Kirkland9$'as a password. Click Create user button. User will be created. Now you have two users.

two users to database

Select reg user in users drop down list and click Add button. MySQL Account Maintenance window will be displayed. Mark only Select, Insert, Update and Delete check boxes. The regular user you will use on your web pages to inser, update or search your products ot customer records.

Add user to database

Click make changes button and your user will be added to the database.

Now you have to create connect.php file with server, user, password, and database name as they were created in previous steps.

<?php

$hostname = "localhost";
$dbuser = "spillout_reg";
$dbpassword = "Kirkland9$";
$dbname = "spillout_mydb";

?>

My eBooks on Amazon.com

US    UK    BR    CA
US    UK    BR    CA
US   UK   BR   CA