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 /path/to/CONTRAST_HOME_DIR $ 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_DIR/bin/db-backup.sh script manually (as the contrast_service user, or whatever user you designated during installation).
$ cd /path/to/<CONTRAST_HOME_DIR> $ sudo -u contrast_service /bin/backup-db.sh Reading Database Configuration Ensuring Database Connectivity: Up Backing up Schema: contrast to /data/backups/db/contrast.20150223.sql