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.

Problem connecting to MySQL through Jailshell

Discussion in 'General Discussion' started by Sindre, Mar 3, 2009.

  1. Sindre

    Sindre Well-Known Member

    Joined:
    Aug 25, 2008
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    We have just moved MySQL from /var/lib/mysql/ to our backup drive mounted on /home2/mysql/ to free up some space and reduce i/o load.

    This is what I have done:

    1. Transferred all files under /var/lib/mysql/ to the new directory /home2/mysql/, preserving permissions and file ownership.

    2. Set the following options in /etc/my.cnf:

    Code:
    [client]
    socket=/home2/mysql/mysql.sock
    
    [mysqld]
    datadir=/home2/mysql
    socket=/home2/mysql/mysql.sock
    
    No problems there. Websites load just fine, and I am also able to access MySQL via SSH if logged in as root or an account with bash shell. However, any cPanel user with Jailshell access get this error message when connecting to MySQL via SSH:

    Code:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/home2/mysql/mysql.sock' (2)
    
    I suspect this error occurs because the jailed users cannot see the /home2 partition.

    Is there any solution to this problem without granting the users Bash shell? Is it possible to somehow add the required mount point to the jailshell environment? Are there any additional steps that must be taken to move the MySQL datadir on a cPanel server? I would think this is a quite common task.

    Any advise will be appreciated.
     
  2. Zishan

    Zishan Well-Known Member

    Joined:
    Aug 6, 2005
    Messages:
    104
    Likes Received:
    1
    Trophy Points:
    0
    Try adding -h127.0.0.1 while connecting to mysql from jailshell


    mysql -uCPANEL_USER -h127.0.0.1 -p
     
  3. Sindre

    Sindre Well-Known Member

    Joined:
    Aug 25, 2008
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    Great, it worked! Thank you. :)
     
Loading...

Share This Page