How to stop a running mysql query

前端 未结 3 1177
陌清茗
陌清茗 2020-12-10 01:29

How do I stop a running mysql query programmatically?

The problem I\'m facing is that a query is constructed using user supplied data, and may occasionally take a v

相关标签:
3条回答
  • 2020-12-10 01:36

    You can issue MySQL specific commands through the standard libraries provided by MySQL and run KILL QUERY. Possibly it's best listing the processes and figuring out which thread you need to kill first.

    Depending on your application this might create a security issue though (since you need to give more privileges to the connecting application user).

    0 讨论(0)
  • 2020-12-10 01:48

    A separate JDBC connection is required, which means you'll have to create a new database handler instance. Execute SHOW PROCESSLIST statement and then loop through the results and execute a KILL statement for each thread id found for the given user.

    The only reliable way I can think to do this is every user would have to log in to the database under a different user name, then get all thread id's for that user and kill all their threads.

    0 讨论(0)
  • 2020-12-10 02:02
    SHOW PROCESSLIST;
    KILL <thread_to_be_killed>;
    

    Refer to the documentation for additional details

    Show The Process List

    Kill A Running Thread

    0 讨论(0)
提交回复
热议问题