development

Diagnosing and Fixing '-bash: mysql: command not found'

The error -bash: mysql: command not found means your shell cannot locate a MySQL client binary in the directories listed in the PATH environment variable. This is not a MySQL se...

Mara Ellison
Diagnosing and Fixing '-bash: mysql: command not found'

The error -bash: mysql: command not found means your shell cannot locate a MySQL client binary in the directories listed in the PATH environment variable. This is not a MySQL server problem unless you also cannot connect to a running server. This guide explains how to diagnose whether MySQL client tools are installed, how to find them if they exist, and how to add them to PATH so the shell can start the client.

What the error means at a high level

-bash: mysql: command not found is a shell message, not a MySQL server message. The shell searches each directory in PATH for an executable file named mysql. If none matches and no valid mysql binary is found, Bash reports command not found. Common causes include a missing MySQL client package, an incomplete install, or a correct install placed in a directory not in PATH. Note: this is distinct from access denied errors or connection failures, which indicate a client-server communication issue after the client is found.

Verify whether MySQL client is installed

Before changing PATH, confirm whether a MySQL client is present and where binaries may reside. Use system package tools and filesystem searches to verify install status.

Check package manager state

On Debian and Ubuntu, check if the mysql-client package is installed:

dpkg -l | grep mysql-client

On RHEL, CentOS, and Fedora, check with:

rpm -qa | grep mysql

On macOS with Homebrew, run:

brew list | grep mysql

Related Reading

More pages in this topic cluster.

For i in range 4: A Practical Guide to Python’s Range-Based Loop

In Python, the expression for i in range(4): iterates four times, with i taking the values 0, 1, 2, and 3. This sequence starts at 0 by default and stops before the stop value,...

Read next
Mermaid Recipe: A Technical Guide to Diagram-as-Code Syntax and Usage

Mermaid is a diagramming and charting tool that uses text-based definitions to generate flowcharts, sequence diagrams, class diagrams, Gantt charts, and more directly in the bro...

Read next
How to View a Website's Code

To view a website's code is to inspect the technologies, rules, and structure that define its layout, behavior, and content in a web browser. Most modern browsers ship with deve...

Read next