I am unable to connect to the MySQL server. I get the error:
Access denied for user 'mrchad'@'int.vital.web7.x10hosting.com' (using password: NO)
I am unable to connect to the MySQL server. I get the error:
Access denied for user 'mrchad'@'int.vital.web7.x10hosting.com' (using password: NO)
Your Database information is wrong.
Read How to create MySQL Database and User
If you feel my post is useful then clickto give Reputation (bottom left corner of this post)
X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership
Tech Community | Gouri
i thought that but it's not. nothing in my configuration file includes mrchad (apart from referencing to my account before the username) plus it would say access denied to localhost if it was a problem on my end whereas it says access denied to (i'm guessing) the MySQL server for x10hosting.
thanks for the advice anyway.
You need to make sure you're connecting to localhost with your username AND password for whatever account you are using to access the database. It's considered insecure to use your default cPanel username/password to log into MySQL in your scripts because you're leaving your password out in plain text. The reason Gouri linked you to how to create a new MySQL user is because you should link a new user (with different password) to your database you are trying to connect to and then use the newly created username/password and put it into your script/software. Make sure you set up the permissions for the user if you create one, otherwise you will get another "Access denied" message.
Also, if it's a user you created in cPanel to use with a specific database note that it requires "[cpanelusername]_username" without quotes and brackets.
Example of logging into MySQL via script and basic MySQL in PHP:
PHP Code:$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$db_selected = mysql_select_db('mysql_database', $link);
Last edited by Jake; 07-08-2011 at 07:29 AM. Reason: Added example
You know where the error is happening? You write the code?
Read the error. It is using your cPanel name and no password. Somewhere, your script is trying to connect to the MySQL server with the default values, ie, not the values in your configuration file. Blanks.
Did you forget to include your configuration file into the script?
Nothing is always absolutely so.
that's the thing. i'm not using my default cPanel username/password to connect to the database. i am using different names to my cPanel name.
all permissions are set correctly and i am setting up the configuration details correctly (it works fine on my localhost). i have edited the username, password and database information appropriately but i get this error.
i don't know why it is using the cPanel username and password. yeah, the configuration is set up correctly. as i said previously, it works fine on my computer (localhost) however not when i upload it.
i did find this article in the wiki:
http://x10hosting.com/wiki/MySQL_Con...lient_computer
i followed those steps (as best i could) however didn't seem to resolve the issue.
Show your code. ******* out any password.
Nothing is always absolutely so.
then to connectPHP Code:<?php
// Database configuration.
$config['hostname'] = 'localhost';
$config['username'] = 'mrchad_username';
$config['password'] = 'password';
$config['database'] = 'mrchad_database';
PHP Code:public function __construct($host, $username, $password, $database) {
$connect = @mysql_connect($host, $username, $password, $database);
$select = @mysql_select_db($database);
if(!$connect || !$select) {
exit('Failure to connect ('. mysql_error() .').');
}
}
I see no connection between the two pieces of code.
Nothing is always absolutely so.