A free database management system called How to Fix MySQL Command Not Found? is compatible with Windows, Linux, and macOS. Regardless of the operating system you are running, the ‘Command Not Found’ error may display. It means that because your system was unable to locate the executable file, it was unable to start the MySQL service.
You may learn How to Fix MySQL Command Not Found? error on Windows, Linux, and macOS by reading this article.
- A Windows, Linux or macOS-based system with an administrator account
- A functioning local installation of MySQL
Reasons for the error “Command Not Found”
The system scans its directories and tries to run the command you input to start the MySQL interface each time you enter it.
The “Command Not Found” error means that the program you attempted to launch could not be found by your system. The following are the top two causes of this error:
- Corrupt MySQL installation: In some cases, there may be corruption during the MySQL installation process. In that instance, a brand-new MySQL installation is required. If you need help installing MySQL, our resources can make the process simple for you to do on CentOS 7, Ubuntu 18.04, or Windows.
- There is no PATH environment variable set: After making sure MySQL is active and operating, the next step is to choose the proper route. The PATH variable contains a list of all the folders your system searches through while trying to locate a command you typed into the terminal.
- The error message “Command Not Found” is displayed if you run a command and it cannot be found in any of the directories in your configured PATH.
The steps for setting the PATH environment variable in Windows, Linux, and macOS are described in the sections that follow.
Fix the Windows ‘Command Not Found’ MySQL error
Open the Windows cmd prompt, then type the following command to start MySQL:
root MySQL -u -p
The system displays the following error if it is unable to carry out the command. To solve the problem, adhere to the methods below.
- 1: Select This PC from the Windows Start Menu by navigating there.
- 2: On the Properties tab, click.
- Now select Advanced System Settings.
- Click the Environment Variables button.
- Single-click the Path system variable, and then click the Edit button.
- Select New to add the correct path for your MySQL folder.
- Retrieve the full path of your MySQL installation. In this example, MySQL is on the C: partition in the Program Files folder.
- Find the bin folder within MySQL and copy the path.
- Paste the full path to the Edit Environment Variable window and click OK to save your changes and exit the screen.
- Restart the cmd interface and enter the initial command once again:
MySQL -u root -p
Enter your password (if you predefined one).
How to Fix MySQL “Command Not Found”? You have successfully logged in to your MySQL bash shell and can start working on your databases.
Fix MySQL Command Not Found MySQL error (Ubuntu 18.04, CentOS 7)
The steps to take How to Fix MySQL “Command Not Found”? error on CentOS 7 or Ubuntu 18.04 is described in this section of the guide. With regard to both Linux distributions, the commands are identical.
Enter the following command in your terminal window to launch the MySQL shell:
root MySQL -u -p
The error message reads “Command Not Found.” Edit the. Bash profile file to correct it.
1: List the directories that the system looks in when a command is run. Enter the following command in your terminal window to do this:
return $PATH
A current list of all the directories it searches is provided in the output.
2: To add the path to the MySQL directory, open the .bash profile file. Use your preferred text editor (e.g. nano) to edit the file:
nano .bash profile
3: Add a line at the end of the file that specifies the location of your MySQL folder:
export PATH=$PATH:/home/location/of/MySQL/bin/folder
4: Let’s look at an example of an edited .bash profile file.
Save and exit the file.
5: Run the standard command to launch MySQL:
MySQL -u root -p
6: You have successfully accessed MySQL (MariaDB) on CentOS 7:
Or Ubuntu 18.04:
Fix the macOS MySQL’s Command Not Found error
The same guidelines that apply to Windows and Linux also apply to macOS. The PATH variable causes the common error to appear on different operating systems. In the directories that it scans, the system is unable to locate executable files.
Enter the following command to modify the. Bash profile file on macOS:
Bash profile -t
Put the location of your MySQL bin folder there:
PATH=$PATH:/usr/local/MySQL/bin export
File exit and saving.
To access the MySQL monitor, type the following command:
root MySQL -u -p
Your attempt to access your MySQL shell has been successful.
Conclusion
The identical MySQL error, how to Fix MySQL “Command Not Found”? even if it is impacting a different group of apps, can be fixed using these general methods. Now you may freely and effectively interface with your databases using MySQL.
See our article on the “Access Denied for User Root@Localhost” error that typically shows when trying to connect to MySQL using the root user after new MySQL installations.