MySQL backup fails with status code 6 : Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Article: 100074583
Last Published: 2025-08-28
Ratings: 0 0
Product(s): NetBackup

Problem

When a MySQL instance has been configured to use a UNIX socket file for local connections, the MySQL backup job can fail with status code 6, because the backup command can't connect to the local MySQL server through socket '/tmp/mysql.sock' (2).

Error Message

The job details may have such error messages:

10:56:05 上午 - Info bphdb (pid=20481) Backup started
10:56:05 上午 - Error bpbrm (pid=691628) from client mysqlhost: ERR - MySQL database name is not present for backup
10:56:05 上午 - Error bpbrm (pid=691628) from client mysqlhost: ERR - bphdb exit status = 6: the backup failed to back up the requested files
10:56:05 上午 - Info bphdb (pid=20481) done. status: 6: the backup failed to back up the requested files

nbmysql debug log has such errors:

11:14:54.438 [20482] <4> main: Found credentials with cred_name: mysqlhost, username: root and password: ******
11:14:54.438 [20482] <2> DBConn: Loading MySQL library - /usr/local/mysql-8.0.25-linux-glibc2.17-x86_64-minimal/lib//libmysqlclient.so
11:14:54.442 [20482] <8> setMysqlOptions: Host is: localhost
11:14:54.443 [20482] <16> connectToDB: Failed to connect to MySQL. Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
11:14:54.443 [20482] <16> performOperation: Failed to connect to the MySQL server as 'root'@'localhost'  with port 3306
11:14:54.443 [20482] <16> main: An error occurred while performing  backup

Cause

The MySQL instance has been configured to use UNIX socket file for local connections, for example:

mysql     31445  1.6 41.9 7549852 3351532 ?     Sl    2024 8117:21 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/lib/mysql/mysqld.log --open-files-limit=65535 --pid-file=/var/lib/mysql/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=3306

But the backup command '/usr/openv/netbackup/bin/nbmysql' can't recognize it, so it will use '/tmp/mysql.sock' as the socket file by default, and that will cause database connection failure:

Loading MySQL library -/usr/local/mysql/lib/libmysqlclient.so
Failed to connect to MySQL. Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Failed to connect to the MySQL server as 'root'@'localhost' with port 3306

Solution

This issue has been fixed in NetBackup 10.2 and newer versions.

For the NetBackup 10.1 and 10.1.1 releases, please contact Cohesity Technical Support to get the following EEBs:

  • NetBackup 10.1: Etrack 4091600
  • NetBackup 10.1.1: Etrack 4202510

After installing the EEB, it is necessary to configure an environment variable for the root user in the .bashrc:

export MYSQL_SOCKFILE_3306=/var/lib/mysql/mysql.sock

After making the change, restart the NetBackup services on the MySQL database host.

 

References

Etrack : 4202510 Etrack : 4191600

Was this content helpful?