Solution to bash: mysql: command not found

When checking the mysql version after installing mysql

mysql --help |grep Distrib

Reason: This is because the system will look for the command under /usr/bin by default. If the command is not in this directory, of course, the command will not be found. What we need to do is to map a link to the /usr/bin directory, which is equivalent to Create a link file.
First of all, you need to know the full path of the mysql command or mysqladmin command. For example, the path of mysql is: /usr/local/mysql/bin/mysql, we can execute the command like this:

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

Here are the additions:

Under Linux, when mysql is running normally, enter the mysql prompt:
mysql command not found

Don't worry when you encounter -bash: mysql: command not found. This is caused by the lack of mysql in the /usr/local/bin directory. You only need the following method to establish a soft link, which can be solved:
put the mysql installation directory, such as MYSQLPATH/ bin/mysql, mapped to the /usr/local/bin directory:
# cd /usr/local/bin
# ln -fs /MYSQLPATH/bin/mysql mysql

There are other commonly used commands such as mysqladmin, mysqldump, etc., which can be solved by this method when they are not available.
Note: where MYSQLPATH is the actual installation path of mysql

 

Then: mysql --help |grep Distrib succeeded

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970096&siteId=291194637