Solution to bash: mysql: command not found [linux mysql command]

question

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

. If you encounter -bash: mysql: command not found, don’t worry. This is caused by the lack of mysql in the /usr/local/bin directory. Only You need the following methods to solve it:

1.vim ~/.bash_profile 最下面写 export PATH=$PATH:/usr/local/mysql/bin(你的安装bin目录)  

:wq 保存退出

2.source ~/.bash_profile

然后就直接可以实现了 给分吧 亲自试验过

 

3.

>>mysql  -uroot -p

>>输入密码

 

或者另一个原因:

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

把mysql安装目录,比如将MYSQLPATH/bin/mysql,映射到/usr/local/bin目录下: 
# cd /usr/local/bin
# ln -fs /MYSQLPATH/bin/mysql mysql

还有其它常用命令mysqladmin、mysqldump等不可用时候都可按用此方法解决。
注:其中这个MYSQLPATH是mysql的实际安装路径

Guess you like

Origin blog.csdn.net/qq_34591972/article/details/131103439