Skip to content

The ‘MySQL command not found’ error usually means the MySQL software is either not installed on your system or its installation path is not included in your system’s PATH environment variable. This guide covers how to resolve the issue.

Understanding the error

When you try to run MySQL from the command line and receive the ‘MySQL command not found’ error, it’s because the system cannot locate the MySQL executable in the directories listed in the PATH environment variable. This error is common in new installations or when switching between multiple MySQL versions.

Checking MySQL installation

First, verify whether MySQL is installed. Run the following command in your terminal:

mysql --version

If MySQL is installed, this command returns the version. If not, you’ll need to install MySQL.

Installing MySQL

If MySQL is not installed, you can download it from the official MySQL website. Installation procedures vary based on your operating system.

For Linux:

sudo apt-get update
sudo apt-get install mysql-server

For macOS:

brew install mysql

For Windows:

Download the installer from the MySQL website and follow the installation wizard.

Updating the PATH environment variable

If MySQL is installed but not recognized, add its directory to the PATH environment variable.

For Linux and Mac:

  1. Find the MySQL installation path:

    which mysql
    
  2. Add the path to your profile script (like .bashrc or .zshrc):

    echo 'export PATH="/path/to/mysql/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
    

    Replace /path/to/mysql/bin with the actual path.

For Windows:

  1. Search for ‘Environment Variables’ in the Start menu.
  2. Edit the ‘Path’ variable under ‘System variables.’
  3. Add the path to the MySQL bin directory.

Verifying the fix

After installation or updating the PATH, run mysql --version again. If the setup is correct, the command should now return the MySQL version.

Troubleshooting

If the problem persists:

  • Ensure you have the correct permissions to access MySQL.
  • Check for typos in the PATH variable.
  • Restart your terminal or system to apply changes.

Additional resources

Basedash is built as an AI-native BI platform, so teams can go from ad hoc SQL to trusted answers and dashboards quickly, without the overhead of traditional BI setup.

Written by

Robert Cooper avatar

Robert Cooper

Senior Engineer at Basedash

Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.

View full author profile →

Looking for an AI-native BI tool?

Basedash lets you build charts, dashboards, and reports in seconds using all your data.