|
|
|
Creating
a MySql database
|
CPanel Tutorials
|
- Log in to your domain contol panel or cPanel.
- Click on 'My Sql databases' link under the subdomain icon.
- You will be taken to 'MySQL Account Maintanance'page . First enter the database name in 'db: ' entry box e.g. product.
- Click 'Add Db' button.You will get a confirmation message that you database is created.
- Now click on [Go back] button to return to 'MySQL Account Maintanance' page to create User name and password for the databse.Enter username and password under the header 'USERS:' .Please note that the password should me 6-8 alplha numeirc characters and should not contain user name.
- click 'Add user ' button. You will get a confirmation message stating your user name and password.Please remember the password and do not share with anyone.
- Click [Go back] button to return to'MySQL Account Maintanance' page to set the user access for the database.
- Ensure that correct user name and database name is selected in the drop down menus.
- Click 'Add users to Db' button and you will get a confirmation message.
- You can copy and paste the code below into any files you have that need to connect to the database.
- Connection strings
$dbh=DBI->connect
Perl ("DBI:mysql:yourdatabasename:localhost","databaseusername","<PASSWORD HERE>");
$dbh=mysql_connect("localhost","databaseusername","<PASSWORD HERE>") or die("I cannot connect the the database because:'.
PHP my sql_error());
mysql_select_db("databasename");
Note: Notice that cPanel automatically prepends yourmain account uasername tothe begining of your database name and user (not the password).
Back to tutorial menu |
|