local MySQL server name

Status
Not open for further replies.

onefavor

New Member
Messages
3
Reaction score
0
Points
1
I have read the previous posts that specify that the host name of my local database is just localhost. I have tried it in my php code:

$servername = "localhost";

and it does not work. I am pretty sure I have the database name, my username, and my password all correct, but I cannot connect. Am I specifying the MySQL sever name correctly?

Thanks,
Bruce
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
I am pretty sure I have the database name, my username, and my password all correct
-
the following settings should be used:
Host/Server Name - [ localhost ] - without the brackets

Port - [ 3306 ] (not necessary)

Username --> Your cPanel username followed by an underscore and the MySQL username you configured in cPanel

Password --> The password that you used when creating the MySQL user

Database --> Your cPanel username followed by an underscore and the name of the database that you created in cPanel
-
click on the above line

NOTE: Free hosting accounts do not have remote MySQL access.
###
 
Last edited:

onefavor

New Member
Messages
3
Reaction score
0
Points
1
I have seen those instructions, yet I cannot connect. I will try some debug code to try to find the problem. Thanks.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Looks like you may have missed a step during database creation; if you try it now it should work fine. You had created the database and the user, but did not assign the user to the database via the "Add user to database" function at the bottom of the MySQL Databases page in cPanel. Effectively, you should be able to login, but you wouldn't have been able to select a database as the user had permissions to nothing.

It's an easy enough step to miss if you're not using the MySQL Database Wizard :)
 

onefavor

New Member
Messages
3
Reaction score
0
Points
1
Thanks for that. I did miss that the first time through in creating my database, but did catch it upon my review... before your advice here. I don't think that is the problem but I shall check to make sure I have used the correct db username. Thanks.
 
Status
Not open for further replies.
Top