Killing a MySQL query during execution with PHP and AJAX

后端 未结 4 989
萌比男神i
萌比男神i 2021-01-20 16:24

I am creating a custom query builder, when user has created his query he can verify the query syntax by clicking a button. When the user click on the button to verify, An A

4条回答
  •  余生分开走
    2021-01-20 16:57

    First of all, if the purpose of the query is just to check the syntax, do not execute it! execute explain, or add limit 0, or execute against empty database.

    As for the killing, you have to connect to database with root privileges, and issue KILL command (but you need to know the query id). Or you can kill the entire thread. Take a look to mysqli::kill

    Edit: seems you don't need root privileges, to see queries by your user, use SHOW PROCESSLIST command

提交回复
热议问题