The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Remote MySQL error

Discussion in 'General Discussion' started by scoopy, Jan 9, 2008.

  1. scoopy

    scoopy Member

    Joined:
    Aug 18, 2004
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I am trying to setup a site to use a database from another server. The setup is as follows:

    Server 1) contains the database I want to use

    Server 2) contains the wordpress script

    I have added the IP from Server 2 in cPanel under "Add Access Host" on Server 1

    I have configured the script on Server 2 like so:

    Code:
    // ** MySQL settings ** //
    define('DB_NAME', 'server1user_wordpress');
    define('DB_USER', 'server1cpaneluser');
    define('DB_PASSWORD', 'server1cpanelpass');
    define('DB_HOST', 'server1.ip'); 
    I have tried all kinds of combos of usernames (including creating a special DB user as "s1cpaneluser_s1DBuser"... but figure the best option is to use server 1's cpanel user/pass)... but it all comes up (on server 2's domain):

    "Error establishing a database connection"

    I also have tried adding the domain and IP of server 2 in server 1's WHM --> Additional MySQL Access Hosts and the server's phpMyAdmin is showing the remote host in its "User Overview" section.

    What am I doing wrong... or what could be wrong here ?

    thanks,
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Do you have port 3308 open on the firewall?

    Did you you grant access and usage rights to your user on the remote DB?
     
  3. scoopy

    scoopy Member

    Joined:
    Aug 18, 2004
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    We have port 3306 open.

    Maybe I am not understanding how I should be granting these permissions. The only way I can see doing this from cPanel is this way:

    1) Log into cPanel of the server with the database
    2) Add a DB user in section, "MySQL Users - Add New User"
    3) Choose this user for the database in, "Add User To Database"
    4) Check "All Priviledges" option

    Then:

    1) Log into cPanel of the server with the Wordpress files
    2) Update file "wp-config.php" to reflect this user I added on other server (server1cpanelname_user)

    Maybe I got the "server1cpanelname" part wrong ? I am using the user name for that cpanel account in that spot for which cPanel automatically adds to any database user I create.

    thanks,
     
  4. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    It's something you need to do as the MySQL administrator.

    ON the remote system, log into the command line version of MySQL, as root, and perform the following:


    Code:
    GRANT ALL PRIVILEGES ON database.* TO user@server2 IDENTIFIED BY 'password';
    
    If cPanel is installed on Server 1, then you can also do that within PHPMyAdmin, on Server 1 when logged into WHM as root.
     
  5. scoopy

    scoopy Member

    Joined:
    Aug 18, 2004
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Thanks... that worked :)

    Note: had to use server 2's IP... instead of the IP the site is on.
     
Loading...

Share This Page