Setup MySQL Databases

From Lunarpages Web Hosting Wiki

Jump to: navigation, search

Many of the scripts and services you wish to install and get running use MySQL databases to store the information on the web site. The information is then pulled from the databases, at the request of the script and then displayed to your readers. Here we will help explain how to setup a MySQL database in cPanel.

Contents

How to Setup MySQL Databases in cPanel

First thing to start with would be to login to cPanel. Once you are in, scroll down the front page until you reach the icon that reads, "MySQL® Databases". Click it to be taken to the MySQL Database Management web page.

Create a MySQL Database

The first thing to do is create a name for the new database. Under "Current Databases" you should see an empty text box like this one:

Image:cpnewdatabase.png

Type the name you wish to use for your database here. Make sure you make note of the name you used, and then hit the "Create Database" button.

Create a MySQL Database User

Now if you scroll down to about half way on the MySQL Database Management web page, you see a section titled, "Current Users". Under this text, you should see two empty text boxes. One box is for your database's user name and the other is for your user name's password. These should be unique to this database and should not be your account user name and password.

Image:cpdatbaseuser.png

Also, make the password 6-8 alpha-numeric characters, and it should not contain the user name. Make note of both the user name and password you used, and then hit the "Create User" button.

Granting User Access to a MySQL Database

The last step would be to add the user you have created for the MySQL database to the database itself. You should see where to do this under "Add Users To Your Databases".

Image:cpdatbase3.png

Ensure that you have the correct user name and database name selected from the drop down menus. For "Privileges" make sure only the "All" check mark box is selected. Once you have made your selection in both of the drop down boxes, hit the button named, "Add User to Db". You have now successfully created a new MySQL database.

You can now copy and paste the code below into any files you have the need to contact to the database.


Please Note: If you have any databases that use your cPanel user name and password, you would need to update your configuration files to reference the new password. We recommend to avoid this issue is to create an independent user for your each of your databases. That way the password is constant and not dependent on your cPanel password.

To create a separate user in cPanel, click on the MySQL icon, create user, then assign the user to your database, granting 'dba' access (full privileges).

Want to read this in another language?

Lunarpages Deal: Save $72 on your next Business web hosting plan! Starting at $18.95 per month, this an offer you can't miss. Perfect for business and e-commerce hosting sites, comes with free e-commerce tools and a TremenDesk Help Desk. Limited time offer!


Personal tools