Databases play a crucial role in managing and storing data for various applications. MySQL and MariaDB are two popular relational database management systems that are widely used for their performance, scalability, and robustness. In certain scenarios, such as when an application is malfunctioning or when a user is hogging resources, it may become necessary to terminate active user connections to the database server. This helps ensure the stability and performance of the system and prevents potential data corruption or loss.
In MySQL and MariaDB, each user connection corresponds to a specific process, identified by a unique process ID. To terminate an active user connection, you must first identify the process ID associated with that connection, and then execute the appropriate command to kill the process. Administrators should exercise caution when terminating connections, as abrupt disconnection can lead to data loss or inconsistencies.
This guide will walk you through the process of terminating active user connections to a MySQL or MariaDB server, step by step. By following these instructions, you'll be able to identify and disconnect specific user connections, thus maintaining the overall stability of your database server.
mysql -u root -p
Replace “root” with your MySQL or MariaDB username if necessary. You will be prompted to enter your password.
SHOW FULL PROCESSLIST;
KILL process_id;
Replace “process_id” with the actual process ID you identified in the previous step.
EXIT;
Comment anonymously. Login not required.