Problem connecting to MySQL through Jailshell

Sindre

Well-Known Member
Aug 25, 2008
46
0
56
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.
 

Zishan

Well-Known Member
Aug 6, 2005
107
1
168
Try adding -h127.0.0.1 while connecting to mysql from jailshell


mysql -uCPANEL_USER -h127.0.0.1 -p