We help IT Professionals succeed at work.

what is the servername, username and password for my site?

NewWebDesigner
NewWebDesigner asked
on
I am trying to create a new database on my server, but am not sure of my server's name, username and password.  What are you best guesses what the default values are?

website name:  www.webdesignrandd.com
Comment
Watch Question

Commented:
why don't You ask your hosting helpdesk?
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
Do you log into managing your site?  Try those or do as has been suggest and ask your host.

Author

Commented:
they suck.  what is your best guess as to servername?  is it usually the domain name?
Top Expert 2013

Commented:
The server name is probably the same as the domain name, and if you are just creating the DB then the user name and password may be blank.

Otherwise talk to the host whether they suck or not, they are the only ones with the information you need.


Cd&

Commented:
do you use cpanel or something similar?

Author

Commented:
Yes! i use cpanel and my company is webhostingpad

Author

Commented:
This is the code I am trying to run on the server.
<?php
$con = mysql_connect("localhost","webdesig_one","aSRGgQGB");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("webdesig_test", $con);
$sql = "CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>

Open in new window


here is the error when I run the code, "Could not connect: Access denied for user 'webdesig_one'@'localhost' (using password: YES)"
Top Expert 2013

Commented:
You said you were hosted, why would be trying to connect to localhost.  That is on your own computer. You have to connect to the database on the host's servers.


Cd&


Top Expert 2013

Commented:
When you go into cpanel, look in the address bar to see what server you are, because that is probably where your database is.




Cd&
Commented:
if you have a cpanel you have to create a database then they will give you the database information and also the connection string that you should put in mysql_connect()

you can see images below for how to create the mysql DB

1.select mysql
mysql.jpg

2.Type in a name for your new database and click the “Add DB” button.
db.jpg

3.Then, type in a Username and a Password into the relative fields and click the “Add User” button.
 user.jpg

4.Once your Database and User have been created, you need to give that user permission to use that database. We do this by selecting the username we created from the drop down and the database we created from the drop down, making sure the “All” checkbox is selected and clicking the “Add User to DB” option.
 permissions.jpg

5.The last thing you will need is the MySQL server hostname. If this hasn’t been supplied to you by your web host, you can get it from this screen in this location:
 server.jpg

i hope that help
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
Great explanation @mt_spy

To clarify an earlier post, connecting to localhost is correct if you are running the code on your host.

Author

Commented:
Here is a screen shot of my mysql on my server.  What part of the url should I use for my server name? picture of my mysql screen
RobOwner (Aidellio)
Most Valuable Expert 2015
Commented:
you should use 'localhost'.  that's what i use with my host