Closed Thread
Results 1 to 10 of 10

Thread: Access denied - MySQL

  1. #1
    chadrick51 is offline x10Hosting Member chadrick51 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    5

    Access denied - MySQL

    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)

  2. #2
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: Access denied - MySQL

    Your Database information is wrong.


    Read How to create MySQL Database and User
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  3. #3
    chadrick51 is offline x10Hosting Member chadrick51 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    5

    Re: Access denied - MySQL

    Quote Originally Posted by Gouri View Post
    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.

  4. #4
    Jake's Avatar
    Jake is offline Developer Jake is an unknown quantity at this point
    Join Date
    Apr 2005
    Location
    Winona, MN
    Posts
    2,084

    Re: Access denied - MySQL

    Quote Originally Posted by chadrick51 View Post
    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 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

  5. #5
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,635

    Re: Access denied - MySQL

    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.

  6. #6
    chadrick51 is offline x10Hosting Member chadrick51 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    5

    Re: Access denied - MySQL

    Quote Originally Posted by Jake View Post
    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.
    Quote Originally Posted by Jake View Post
    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); 
    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.
    Quote Originally Posted by descalzo View Post
    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_Con...lient_computer
    i followed those steps (as best i could) however didn't seem to resolve the issue.

  7. #7
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,635

    Re: Access denied - MySQL

    Show your code. ******* out any password.
    Nothing is always absolutely so.

  8. #8
    chadrick51 is offline x10Hosting Member chadrick51 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    5

    Re: Access denied - MySQL

    Quote Originally Posted by descalzo View Post
    Show your code. ******* out any password.
    PHP Code:
    <?php
        
        
    // Database configuration.
        
    $config['hostname'] = 'localhost';
        
    $config['username'] = 'mrchad_username';
        
    $config['password'] = 'password';
        
    $config['database'] = 'mrchad_database';
    then to connect
    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() .').');                
                    
                }
                
            } 

  9. #9
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,635

    Re: Access denied - MySQL

    I see no connection between the two pieces of code.
    Nothing is always absolutely so.

  10. #10
    chadrick51 is offline x10Hosting Member chadrick51 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    5

    Re: Access denied - MySQL

    Quote Originally Posted by descalzo View Post
    I see no connection between the two pieces of code.
    i just posted the relevant bits. i've managed to resolve the issue now. thanks for the help and advice anyway.

Closed Thread

Similar Threads

  1. Access denied to mysql
    By kovacsi76 in forum Free Hosting
    Replies: 3
    Last Post: 06-20-2010, 03:35 PM
  2. mysql access denied
    By chegos in forum Free Hosting
    Replies: 3
    Last Post: 06-10-2010, 07:47 AM
  3. access denied in mysql
    By diaga09 in forum Free Hosting
    Replies: 5
    Last Post: 01-11-2010, 10:04 AM
  4. mysql access denied
    By ufclan in forum Free Hosting
    Replies: 6
    Last Post: 02-28-2008, 11:21 PM
  5. Replies: 3
    Last Post: 02-14-2008, 01:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers