Run a SQL statement in MySQL on each connection

54
January 12, 2019, at 5:50 PM

I must be going nuts here, but I could swear I read about a configuration option in MySQL that will run the defined SQL statement on every successful connection to the database, with the cavet that it would not run for root or those with a certain privilege to prevent shutting the server down with a bad sql statement here.

Was I imagining things or do folks know of such a parameter?

I have dug though the MySQL documents and so far I'm not turning up with any success.

Note, this is NOT for the client supplied sql statements, but instead for a statement that the server itself runs regardless of who connects and for what task, and great for tracking who connects with what account if general_log was not enabled for some reason or special handling is required.

Answer 1

Found it.

The parameter is named init_connect and will run the defined sql for each connection, except for those with the super privilege. No result sets are produced by this though so selects are not recommended for this.

READ ALSO
How to access a variable from a knex query inside of a second knex query?

How to access a variable from a knex query inside of a second knex query?

I have the following route where I want to get the sum associated to an id I get from the first query

20
How to break out values in a row to be in its own field based on a date value

How to break out values in a row to be in its own field based on a date value

In the Table Setup below you will see that the Amount data is broken down in various rows in the tableI am creating a view where i want to break this out where each Amount value is in its own field based on the CreatedDt field

25
SQL-queries in server.js or in react-component file?

SQL-queries in server.js or in react-component file?

I'm totally new at using Expressjs and React

45
Laravel app using Jaws Maria DB on Heroku getting MYSQL errors

Laravel app using Jaws Maria DB on Heroku getting MYSQL errors

I have a Laravel app on Heroku using Maria DB as a Add onMy App is up and running

23