Database backup gives error

  • Updated


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/

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 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/ 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/
  Reading Database Configuration
  Ensuring Database Connectivity: Up
  Backing up Schema: contrast to /data/backups/db/contrast.20150223.sql

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request