Database access denied

Status
Not open for further replies.

loveandn

New Member
Messages
3
Reaction score
0
Points
1
Hello I'm getting access denied on my website to the database. My config file looks like this

<?php
define('DB_HOST', 'host IP');
define('DB_USER', 'username'); \\I already added my user to the database in the control panel
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'database name');
?>

I'm getting this error
Failed to connect to server: Access denied for user 'username'@'xo2.x10hosting.com' (using password: NO)
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
My config file looks like this
the following settings should be used:
Host/Server Name - [ localhost ]

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 above

Remember: Free hosting accounts do not have remote MySQL access.
 

loveandn

New Member
Messages
3
Reaction score
0
Points
1
the following settings should be used:

click on above

Remember: Free hosting accounts do not have remote MySQL access.
yes my config is like that. I got the settings right. Still failed to connect to server.

Failed to connect to server: Access denied for user 'my username here'@'xo2.x10hosting.com' (using password: NO)
 

loveandn

New Member
Messages
3
Reaction score
0
Points
1
Ok got it working. My config file is correct but on my actual execution php file I forgot to add DB_PASSWORD at this line "$link=mysql_connect(DB_HOST, DB_USER);" it should be "$link=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);"

Thanks for helping ^^
 
Status
Not open for further replies.
Top