😄This is my project for IS214:Database Theory in SJTU. I develop a log monitor and status monitor for MySQL Database with python. For log monitor, I referred to repo MySQLMonitor. Based on that, I added a status monitor to this project.
-
Install MySQL. A guideline for installing can be found here.
-
Install PyMySQL using
pip install pymysql
in your terminal. If you install pymysql successfully, you can run pymysql_demo.py to take a peek of pymysql. Don't forget to change the parameters in line 3 and SQL command in line 11.
- In monitor.py, both log monitor(function) and status monitor(class) are defined.
- utils.py offers functions to connect MySQL database and execute SQL commands.
- Both main_logmonitor.py and main_statusmonitor.py are the running file.
-
Open file config.ini . Usually you only need to change passward and db_name to your own in this file.
-
Run main_logmonitor.py to start Log Monitor. It can monitor the commands used by all users of the database in real time. The output is shown as follow:
- Run main_statusmonitor.py to start Status Monitor. It can monitor the status like using tables, threads, connection list of the database in real time. The output is shown as follow: