Please Login or Register

Knowledgebase

Can't connect to mySQL database.

All new hosting accounts come with mySQL database enabled. You can setup your database, database users and manage them all from your cPanel. Login and then select the "MySQL Databases " icon. From here you can set up databases and then manage them using the phpMyAdmin facility. If you have written your own PHP (or other) script to access your mySQL database, ensure you are using your correct username and password to access the database, the database name will also be the same as your username. i.e. for PHP, you can open a connection to your database as follows (where: USERNAME = your hosting username and PASSWORD = your password and MYSQLUSERNAME = the name you chose to manage your mysql database and DBNAME = the name you chose for your database)

<?php

$db = mysql_connect("localhost", "USERNAME_MYSQLUSERNAME", "PASSWORD");

mysql_select_db("USERNAME_DBNAME",$db);

?>

The above will connect to mySQL with your username and password, then selects your mySQL database.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article


Powered by WHMCompleteSolution

Language:

Quick Navigation

Client Login

Email

Password

Remember Me

Search