How to Fix the "MySQL Command Not Found" Error?

If you encounter the "MySQL command not found" error when trying to run MySQL commands in your terminal or command prompt, it typically indicates that the system cannot locate the MySQL binary files. Here are steps to resolve this issue on various operating systems:

1. Verify MySQL Installation

First, confirm that MySQL is installed on your system:

  • On Linux, use the command:

mysql --version



  • On Windows, open Command Prompt and type:

mysql --version



If you get a version response, MySQL is installed but might not be in your PATH. If not, install MySQL or troubleshoot the installation.

2. Add MySQL to the System PATH

Your system's PATH variable tells the OS where to look for executable files. If MySQL isn't in this path, you'll get the "command not found" error.


For Linux

  1. Locate the MySQL directory, often found in /usr/bin/mysql or /usr/local/mysql/bin.

  2. Open your .bashrc or .zshrc file:

nano ~/.bashrc


  1. Add the following line, replacing with the MySQL directory path:

export PATH=$PATH:/usr/local/mysql/bin



  1. Save and reload the configuration:

source ~/.bashrc



For macOS

  1. Find the MySQL path, usually /usr/local/mysql/bin.

  2. Open the terminal configuration file (e.g., .zshrc or .bash_profile).

  3. Add the MySQL path:

export PATH=$PATH:/usr/local/mysql/bin


  1. Save and reload:

source ~/.zshrc


For Windows

  1. Locate the MySQL installation folder (commonly C:\Program Files\MySQL\MySQL Server 8.0\bin).

  2. Go to System Properties > Environment Variables.

  3. Find the Path variable under System Variables, click Edit, and add your MySQL path.

  4. Click OK and restart Command Prompt.

3. Test the MySQL Command

After adding MySQL to your PATH, test if the command works by opening a new terminal or Command Prompt and typing:


mysql --version



If configured correctly, you should see the MySQL version, indicating the error is resolved.


Was this answer helpful? #0 #0
 

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Related Questions

Submit your Query

  • I'm not a robot

Browse by ServicesBrowse by Services

Resource Library

What is Cloud Computing

Understand the term cloud computing, the ongoing trend, its playing field, future growth and how industry...

Myths about Cloud Computing

Cloud computing, in the recent years, has become a subject of significant discussion among the industry experts.

Download Now

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Submit Query

Please fill in the form below and we will contact you within 24 hours.