gcc -o test test.c -I/usr/include/mysql/ -lmysqlclient -Wall -g
mysql_real_connect中
If unix_socket is not NULL, the string specifies the socket or named pipe to use. Note that the host parameter determines the type of the connection.
If options->host is "localhost" mysql_real_connect() tries to connect to server via unix socket (or other ways to optimize communication on localhost, see documentation). In this case the name of unix socket must me specified in the pre-last argument of mysql_real_connect() which is empty string in the code above.
That is why if --mysql-host command line option is "localhost" percona-playback can not connect to server. The workaround is to use 127.0.0.1 instead of "localhost".