Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    4

    Default MySQL. Access between cPanel accounts.

    Hi all
    I have two domains in the same hosting services. Each of them has a database named dom1_db and dom2_db respectively, and each of them has a user named dom1_userdb and dom2_userdb. Is there any way for dom1_userdb to login and access to dom2_db? I'd like to share some tables, because replicating information should be a bit dangerous because it exposes to data inconsistencies. It would be a big help to access to the other database.

    Thanks in advance!

  2. #2
    Member
    Join Date
    Aug 2004
    Posts
    472

    Default

    You can grant access from for the d1 to dbuser2 and vice versa. If you have shell access, you can use the following steps from the mysql prompt.
    Code:
    grant all privileges on db1.* to dbuser2@localhost identified by 'password';
    grant all privileges on d21.* to dbuser1@localhost identified by 'password';
    www.cliffsupport.com
    i WebManager | Access WHM from your iPhone

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    4

    Default

    Thanks, David, but when I try to grant access that way, MySQL returns me the error
    Access denied for user 'dbuser2'@'xx.yy.zz.tt' to database 'db2' It's own DB!! And of course I have access with dbuser2 to db2 because it's the main user, the user which I login to DB from MySQL GUI tools with, and the admin user which I login to cPanel for that domain with.

    Both databases are in the same server, as I stated before.

    It seems that cPanel not only creates users with no access to other databases (which is of common sense) but also with no privilege to grant access to other users, by default. So I was asking for any other way to do that.

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,720
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    What I do in this scenario is create another user for my DB in cPanel and grant it all privileges (or whatever privileges are desired) to the database(s) I want that user to have access to.

    Then from my other website, I authenticate to MySQL as this user I created. Even though this user was created under another domain, this other website can still authenticate to it since it's on the same server and it is using the MySQL user's authentication credentials.

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    4

    Default

    Hi DavidG, and thanks for your answer.
    Since MySQL users created from cPanel are preceded by the cPanel user (often the domain name) in the way "cpuser_dbuser", any user created for domain1 from domain2 are different.
    And if I try to solve this executing the create user command from MySQL Query Browser I get an access denied error.

    Could you explain with detail your workaround for this scenario, please?

    Thanks in advance.

  6. #6
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,720
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by Lironcareto View Post
    Hi DavidG, and thanks for your answer.
    Since MySQL users created from cPanel are preceded by the cPanel user (often the domain name) in the way "cpuser_dbuser", any user created for domain1 from domain2 are different.
    And if I try to solve this executing the create user command from MySQL Query Browser I get an access denied error.

    Could you explain with detail your workaround for this scenario, please?

    Thanks in advance.
    Sure, I was using the below setup myself up until 9 months ago:

    1. Two separate cPanel accounts, let's call them DomainA and DomainB
    2. I had a old database used by DomainA, so I had MySQL user under DomainA, let's call it DomainA_dbuser with access to DomainA_db
    3. Eventually I created DomainB on the same server, but wanted to access DomainA's databases from DomainB.
    4. I just configured my PHP script on DomainB to connect to DomainA_db while authenticating as DomainA_dbuser - connecting to the MySQL server on localhost.
    5. Great Success!


    Now, if you are using a tool to connect to the database remotely (e.g. MySQL's Query Browser Tool), be sure to add your workstation's IP to the allowed IP list, or else you will get an Access Denied message. You can do this by going to the cPanel interface where the database was created and clicking on the "Remote MySQL" icon. If you don't know your workstation's IP address, you can visit a website like WhatIsMyIPAddress .com

  7. #7
    Registered User
    Join Date
    Jul 2009
    Posts
    4

    Default

    I understand your solution, David, but I'm afraid it doesn't apply to my case. It wouldn't allow me to join tables between databases in the way select * from db1.table1, db2.table2 where... etc, which is what I really need.

    Thanks anyway.

Similar Threads & Tags
Similar threads

  1. CPanel-->Mysql --> Access Host
    By NickJ in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 08-14-2005, 07:04 AM
  2. MySQL access issues w/new accounts
    By n_kruse in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-26-2004, 09:06 AM
  3. All Accounts can´t access cPanel
    By cjanjacomo in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 06-10-2004, 12:34 AM
  4. Access MySQL DB from outside Cpanel
    By wimp in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 11-29-2002, 05:14 AM
Tags for this Thread
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube