Databases 5 min read

MySQL Command Shortcuts, Help Commands, and Administration Tips

This guide lists useful MySQL client shortcuts, explains the help command usage, provides common mysqladmin administration examples, and shows how to diagnose high CPU usage by tracing the offending SQL statements through process and performance schema queries.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
MySQL Command Shortcuts, Help Commands, and Administration Tips

This article presents a collection of handy MySQL client shortcuts, such as \? for help, \c to cancel the current command, \r to reconnect, \d to change the command delimiter, \e to write to a file and execute multiple statements, \G for vertical output, \q to quit, and many others including source, status, system, use, prompt, nopager, pager, charset, warnings, and nowarning.

The built‑in help command can be used in several ways, for example mysql> help, mysql> help contents, mysql> help select, mysql> help create, mysql> help create user, mysql> help status, and mysql> help show.

Common mysqladmin operations are demonstrated:

Change password: mysqladmin -uroot -p123 password 123456 Shutdown the server (useful for multi‑instance setups): mysqladmin -uroot -p123 -S /tmp/mysql.sock shutdown Create a database: mysqladmin -uroot -p create hahashen Drop a database (with confirmation warning): mysqladmin -uroot -p drop hahashen Show server variables (e.g., server_id): mysqladmin -uroot -p variables | grep server_id Check if the server is alive: mysqladmin -uroot -p123 ping Reload privilege tables (equivalent to FLUSH PRIVILEGES): mysqladmin -uroot -p123 reload Flush binary logs (useful before setting up replication): mysqladmin -uroot -p123 flush-log When encountering high CPU usage (e.g., sustained 85% load), the article outlines a step‑by‑step troubleshooting process:

Identify the MySQL process ID: ps -ef | grep -i mysql Monitor CPU consumption of that process in real time: top -p 124468 -H (replace 124468 with the actual PID).

Find the corresponding MySQL thread ID:

select thread_id, name, PROCESSLIST_ID, THREAD_OS_ID from threads where THREAD_OS_ID = 124468;

Retrieve the SQL text executed by that thread:

select sql_text from performance_schema.events_statements_current where thread_id = 124468 \G;

These commands help pinpoint the exact statement causing the CPU spike, enabling targeted optimization or termination.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

sqlPerformance MonitoringmysqlDatabase AdministrationCommand-Line
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.