Mysql init_connect in xampp on linux/centos 64 bit not working

I have 64 bit centos server with xampp installed manually at /opt/lampp.
When I attempted to do user logins on the server using init_connect string, all queries fails.
I put the audit_connections table in mysql database, where any user should be able to INSERT.

CREATE TABLE mysql.`audit_connections` (
  `audit_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Audit ID',
  `connections_counter` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Total number of connections',
  `connection_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Internal Connection ID',
  `user_host` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'user@host Parameter',
  `connected_on` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Last connection time',
  PRIMARY KEY (`audit_id`),
  UNIQUE KEY `connection_id_user_host_key` (`connection_id`,`user_host`)
) COMMENT='Auditing MySQL Connections';

Any new user created on the system should be able to INSERT on mysql.audit_connections.
Any luck?

What error do you get?

– Aborted connection 16344 to db: ‘unconnected’ user: ‘’ host: '’ (init_connect command failed)

My Init Connect settings are:


SET GLOBAL init_connect = "
SET collation_connection = utf8_general_ci;
SET NAMES utf8;
SET character_set_server = utf8;
SET collation_server = utf8_unicode_ci;
INSERT INTO mysql.audit_connections (
	`connection_id`, user_host, connected_on
) VALUES (
	CONNECTION_ID(), SYSTEM_USER(), NOW()
) ON DUPLICATE KEY UPDATE
	connections_counter = connections_counter+1,
	connected_on = NOW()
;";

Don’t you execute those commands after having connected to the database?
The error seems to indicate there is no connection. Do you have the commands to connect to the database in your script?

init_connect is actually set in my.ini file under [mysqld] section. So, it is set every time the server starts up.

init_connect = "
SET collation_connection = utf8_general_ci;
SET NAMES utf8;
SET character_set_server = utf8;
SET collation_server = utf8_unicode_ci;
INSERT INTO mysql.audit_connections (
connection_id, user_host, connected_on
) VALUES (
CONNECTION_ID(), SYSTEM_USER(), NOW()
) ON DUPLICATE KEY UPDATE
connections_counter = connections_counter+1,
connected_on = NOW()
;"