Make sure you always double-check which processes you are terminating before running a MySQL query.įor options to further optimize a MySQL Database, read our article on MySQL Performance Tuning. This guide has outlined the easiest way to find and kill MySQL processes. SELECT CONCAT('KILL ',id,' ') FROM information_schema.processlist WHERE user='root' and time>1000 INTO OUTFILE '/tmp/process_list.txt' For example, add time > 1000 to the command to include only the processes with the time value higher than 1000. You can add conditions to the query to narrow down the list of processes in the output file. When you are ready, enter: SOURCE /tmp/process_list.txt Once you have the PID of the command you wish to kill, use kill with the -9 (SIGKILL) flag and the PID of the java process you wish to kill. pgrep -a java will return the PID and full command line of each java process. You could also use pgrep to list all java processes. Open the file and review if those are the processes you want to kill. Here is the command in full: ps -fC java. This query created a file called process_list.txt. SELECT CONCAT('KILL ',id,' ') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/process_list.txt' To specify another user, replace rootwith the desired username. In our case, we entered root as the user. To kill all processes for a specific user, use CONCAT to create a file with the list of threads and statements. MySQL does not have a unique command for killing all processes. How to Kill All MySQL Processes for a Specific User Remember that a user must have proper privileges to be able to kill a process. ” This query ends the connection to the database, including all operations associated with the connection. The shell displays the query status and the number of affected rows: “ Query OK, 0 rows affected (0.06 sec). To kill a MySQL session from the list, use the KILL query followed by the thread Id you noted earlier. Those are usually the ones you want to terminate first. The Timecolumn helps you determine the longest-running processes. Note the Idof the process you want to kill.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |