This is a lightweight bash script designed to provide sysadmins and DBAs with a quick overview of MySQL metrics. It displays critical metrics like InnoDB buffer usage, query performance, and system memory, along with brief explanations of each variable.
Cut and paste each step.
curl -O https://raw.githubusercontent.com/haydenjames/mysqlmonitor-script/main/mysqlmonitor.sh
chmod +x mysqlmonitor.sh
./mysqlmonitor.sh
Done!
or...
Simply cut and paste. This command will download and run mysqlmonitor.sh immediately.
curl -O https://raw.githubusercontent.com/haydenjames/mysqlmonitor-script/main/mysqlmonitor.sh && \
chmod +x mysqlmonitor.sh && \
./mysqlmonitor.sh
Linuxblog.io: MySQL Monitor: A Simple MySQL Monitoring Script - This blog post provides detailed guidance on the variables used in the script, along with links to common MySQL tuning pitfalls and tips to help you optimize your database performance.
When the terminal window's height is smaller than the number of lines the script attempts to display, the terminal starts scrolling. This results in repetitive or overlapping content, making the output unreadable. In the meantime, I've added a check for minimum terminal size. The minimum is 95×55.
Add a --help flag for users who want to see usage information.
Here are some common issues and how to resolve them:
If the script fails to connect to your MySQL server due to missing credentials, you may need to create a ~/.my.cnf
file for automatic authentication.
-
Create the file:
nano ~/.my.cnf
-
Add the following structure to the file:
[client] user=your_mysql_username password=your_mysql_password
-
Secure the file permissions:
chmod 600 ~/.my.cnf
-
Rerun the script.
If you encounter permission issues as a non-root user, try running the script with sudo
:
sudo ./mysqlmonitor.sh
If the script fails to connect even with credentials:
- Ensure the MySQL server is running:
or
sudo systemctl status mysql
sudo systemctl status mariadb
- Verify that the credentials in
~/.my.cnf
are correct.
Thank you for using MySQL Monitor, we hope it helps simplify your database monitoring and tuning tasks!