|Agent Mode||Assess & Protect|
|Main Product Category||Contrast UI|
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
In some fresh vanilla installations of Redhat or CentOS, the server could have an unresolvable hostname. During the installation process, Contrast detects the hostname for the server to set configuration parameters for how to connect to the database.
Example: A default CentOS 5.6 installation sets its hostname to
centos.localdomain, but a corresponding entry isn't added to the /etc/hosts file.
If the hostname is unresolvable, the system defaults to
localhost, which works for other areas of the system. However, the automated backup uses the mysqldump tool that associates the
localhost hostname with a file socket connection instead of a network socket connection.
To resolve this error, set the database hostname to either a resolvable hostname or the IP address assigned to the server. This can be done using the encrypted properties editor tool that ships with the product.
$ cd $CONTRAST_HOME $ bin/edit-properties -e data/esapi -f data/conf/database.properties
Once you're in the properties editor, type the name of the property that you would like to change. In this case, you want to update the value of the
jdbc.host to the new hostname or IP address assigned to the server. Once you update this value, hit Q to quit out of the tool, select Y to save, then enter a comment for your change. You can verify the backup functions by running the $CONTRAST_HOME/bin/db-backup.sh script manually (as the contrast_service user, or whatever user you designated during installation).
$ cd $CONTRAST_HOME sudo -u contrast_service /opt/Contrast/bin/backup-db.sh Reading Database Configuration Ensuring Database Connectivity: Up Backing up Schema: contrast to /opt/Contrast/data/backups/db/contrast.20150223.sql