Issue
Websites are unable to connect to a database with localhost.
Error:
Error establishing a database connection
Environment
- CageFS
Solution
-
Check that /var/lib/mysql is present in your cagefs.mp file:
# grep mysql /etc/cagefs/cagefs.mp
In case it is not, please add it and execute the
# cagefsctl --force-update
-
Check if your mysql.sock file is configured to a custom location in /etc/my.cnf file. If so, create a symlink to the file in /var/lib/mysql to your current mysql.sock file using command (for example, if your current mysql.sock is in the /home/mysql/ folder):
# ln -s /home/mysql/mysql.sock /var/lib/mysql/mysql.sock
Note: If you have specified another location for mysql.sock, then update the aforementioned command accordingly.
- Update CageFS using the command:
# cagefsctl --force-update
Note: You may change the address from
localhost
to127.0.0.1
as a workaround.
This solution, however, is not recommended as it may confuse the customers.
Cause
- MySQL directory might be missing from the CageFS configuration, thus websites have trouble connecting to MySQL from inside the CageFS.
- Another option is that
mysql.sock
file is displaced elsewhere.
Useful Links
https://docs.cloudlinux.com/cloudlinux_os_components/#mount-points
Comments
0 comments
Please sign in to leave a comment.