-bash: mysql: command not found - How to Fix MySQL Not Found Error
The '-bash: mysql: command not found' error in bash indicates that your system cannot locate the mysql command. This usually happens because MySQL isn't installed correctly or its path isn't set up in your environment variables.
Here's how to resolve this issue:
-
Verify MySQL Installation: Run the command
mysql --versionto check if MySQL is installed. If not, install it first. -
Check Environment Variables: Execute
echo $PATHin your bash terminal to see if the output includes the MySQL installation directory. If not, you need to add it to thePATHenvironment variable.For example, if MySQL is installed in
/usr/local/mysql/bin, use the following command:export PATH='/usr/local/mysql/bin:$PATH'Re-run the
mysqlcommand to see if it works now. -
Verify Command Existence: If MySQL is correctly installed and in your
PATH, but the command is still not found, it might be due to permission issues or an incorrect installation location. Try running themysqlcommand using its absolute path, like/usr/local/mysql/bin/mysql.
If you're still unable to resolve the issue, consider reinstalling MySQL and ensure you follow the official documentation's instructions for installation and configuration.
原文地址: https://www.cveoy.top/t/topic/fdQx 著作权归作者所有。请勿转载和采集!