Symptoms
Sites that use "localhost" as the database host will encounter database connection errors while switching to "127.0.0.1" allows for a successful connection.
Description
Scripts will try to connect to the Unix socket if configured to connect to "localhost." They try to connect to the network socket if configured to connect to "127.0.0.1" or another IP address. The socket a script connects to doesn't matter unless CageFS is used. CageFS restricts what resources users have access to. If CageFS isn't configured to allow access to the folder the mysql.sock file is in, scripts attempting to connect to the MySQL Unix socket will encounter connection errors.
Procedure
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Open
/etc/my.cnf
in your preferred text editor. - Ensure that the
datadir
andsocket
entries exist and have the correct values.datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Please note that the above values are the default values and must be replaced with the values specific to your server. - Save the changes and exit the text editor.
- Restart the mysqld service if changes were made to
/etc/my.cnf
./usr/local/cpanel/scripts/restartsrv_mysql
- Open
/etc/cagefs/cagefs.mp
in your preferred text editor. - Ensure that the
/var/lib/mysql
entry exists.
Please note that if the MySQL socket file is not in the default folder, replace/var/lib/mysql
with the folder the socket file is in. - Save the changes and exit the text editor.
- Remount CageFS for all users.
cagefsctl -M
cagefsctl --force-update
Comments
0 comments
Article is closed for comments.