Solution to bash: mysql: command not found

  • 2020-05-15 02:24:13
  • OfStack

root@DB-02 ~]# mysql -u root
-bash: mysql: command not found


Reason: this is because the system will look for the command /usr/bin by default, if the command is not in this directory, of course, the command will not be found, we need to do is to map 1 link to the /usr/bin directory, equivalent to creating a link file.
Must first know mysql command or mysqladmin command the full path, such as mysql path: / usr/local/mysql/bin/mysql, we can execute the command:

# ln -s /usr/local/mysql/bin/mysql /usr/bin

The following is a supplement:

Under linux, when mysql is in normal operation, enter mysql prompt:
mysql command not found

In case of -bash: mysql: command not found, don't worry. This is caused by the loss of mysql in the directory /usr/local/bin. You only need 1 method to establish a soft link, which can be solved:
Map the mysql installation directory, such as MYSQLPATH/bin/mysql, to the usr/local/bin directory:
# cd /usr/local/bin
# ln -fs /MYSQLPATH/bin/mysql mysql

There are other common commands mysqladmin, mysqldump, etc., can be used to solve the problem when it is not available.
Note: where MYSQLPATH is the actual installation path of mysql


Related articles: