Linux 无法找到 mySQL -- 尝试从命令行访问 mySQL 时出现“未找到命令”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8829705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:02:21  来源:igfitidea点击:

Cannot find mySQL -- get "command not found" error when trying to access mySQL from command line

mysqllinuxshellsshcommand

提问by Samantha Slade

I have previously installed, connected and uploaded to a WordPress mySQL database via SSH no problem. The people who run my server made a few configuration changes, and now I get a "bash: mysql: command not found" error when I try to log into mySQL via the command line on the same server to access the same database.

我以前通过 SSH 安装、连接并上传到 WordPress mySQL 数据库,没问题。运行我的服务器的人员进行了一些配置更改,现在当我尝试通过同一服务器上的命令行登录 mySQL 以访问同一数据库时,出现“bash: mysql: command not found”错误。

I am relatively new to all of this, so I am really not sure what to do. When I run "which mysql" I get a message that says there is no mysql in the /usr/bin directories. I can verify that mySQL is running between the fact that my site is still live and functioning and when I ran a command to test mysql (sorry I can't locate that right now) I got a message that said "mySQL works!" I find mysql files in several directories, but I'm not really sure what I am looking for and how I connect to it when I do find it. I am also not sure if this is user error, or if somehow someone moved or hid mySQL from me -- likely user error??

我对这一切都比较陌生,所以我真的不知道该怎么做。当我运行“which mysql”时,我收到一条消息,指出 /usr/bin 目录中没有 mysql。我可以验证 mySQL 是否正在运行,因为我的站点仍然有效并且正在运行,当我运行命令来测试 mysql(抱歉,我现在找不到它)时,我收到一条消息说“mySQL 工作正常!” 我在几个目录中找到了 mysql 文件,但是我不确定我在寻找什么以及在找到它时如何连接到它。我也不确定这是否是用户错误,或者是否有人以某种方式向我移动或隐藏了 mySQL——可能是用户错误?

Any help is appreciated. Thank you!

任何帮助表示赞赏。谢谢!

回答by Alexey Sviridov

If you have mysql server up and running on your server it's not mean you have a mysql client installed on this server.

如果您在服务器上启动并运行了 mysql 服务器,这并不意味着您在该服务器上安装了 mysql 客户端。

try

尝试

ls -l /usr/bin/mysql*

do you see mysql binaries exactly present on system?

您是否看到系统上完全存在 mysql 二进制文件?

One more problem Linux has very strange behaviour when run binaries for another archetecture. for example if you run 32-bin executable on 64-bit system you will get error message "command or file not found", even if binaries actually present!

另一个问题 Linux 在为另一个架构运行二进制文件时有非常奇怪的行为。例如,如果您在 64 位系统上运行 32-bin 可执行文件,您将收到错误消息“找不到命令或文件”,即使二进制文件确实存在!

hope this help.

希望这有帮助。

回答by Roman Newaza

MySQL Server is not MySQL Client.

MySQL 服务器不是 MySQL 客户端。

Check if MySQL is running executing this command:

检查 MySQL 是否正在运行执行此命令:

ps aux | grep mysql | grep -v grep

And install MySQL Client:

并安装 MySQL 客户端:

sudo apt-get install mysql-client # Or your distro command

回答by Madhusudan Mudri

Although the MySQL is running, if you are not able to connect to the server using mysql command, then you might be missing to provide soft links

虽然 MySQL 正在运行,但如果您无法使用 mysql 命令连接到服务器,那么您可能缺少提供软链接

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

须藤 ln -s /usr/local/mysql/bin/mysqladmin /usr/bin

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

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

this should enable you to connect.

这应该使您能够连接。

--Madhusudan Mudri

——马杜苏丹·穆德里