Access denied - MySQL

Status
Not open for further replies.

chadrick51

New Member
Messages
5
Reaction score
0
Points
0
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)
 

chadrick51

New Member
Messages
5
Reaction score
0
Points
0
Your Database information is wrong.


Read How to create MySQL Database and User

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.
 

Jake

Developer
Contributors
Messages
4,057
Reaction score
5
Points
0
Access denied for user 'mrchad'@'int.vital.web7.x10hosting.com' (using password: NO)

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:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$db_selected = mysql_select_db('mysql_database', $link);
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
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?
 

chadrick51

New Member
Messages
5
Reaction score
0
Points
0
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.
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.
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:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$db_selected = mysql_select_db('mysql_database', $link);
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.
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?
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_Connection_Errors#Client_computer
i followed those steps (as best i could) however didn't seem to resolve the issue.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Show your code. ******* out any password.
 

chadrick51

New Member
Messages
5
Reaction score
0
Points
0
Show your code. ******* out any password.

PHP:
<?php
    
    // Database configuration.
    $config['hostname'] = 'localhost';
    $config['username'] = 'mrchad_username';
    $config['password'] = 'password';
    $config['database'] = 'mrchad_database';
then to connect
PHP:
        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() .').');                
                
            }
            
        }
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I see no connection between the two pieces of code.
 
Status
Not open for further replies.
Top