终端无法识别mysqld和mysql命令 [英] Terminal doesnt not recognise mysqld and mysql commands

查看:137
本文介绍了终端无法识别mysqld和mysql命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OSX 10.9.5上运行,并且在尝试重置MySQL root用户密码时,我输入了以下内容:

I am runnin OSX 10.9.5 and while trying to reset my MySQL root pasword I typed this:

sudo mysqld_safe --skip-grant-tables

sudo mysqld_safe --skip-grant-tables

要求输入管理员密码后,出现此错误:

After being asked for the admin password, I got this error :

sudo:mysqld_safe:找不到命令

sudo: mysqld_safe: command not found

我在

cd/usr/local/mysql

cd /usr/local/mysql

此外,我在使用sudo命令时遇到了问题,尽管我在管理员帐户中登录了我的帐户,但它却经常给我拒绝权限,就像使用此命令来解决基本相同的问题(重置我的root密码)

Also, I have a problem with the sudo command, event though I am logged on the admin account my account, It gives me often permission denied, like using this command for basically the same problem ( reseting my root password )

sudo kill cat /usr/local/mysql/data/rodongi.pid

然后我得到了

cat:/usr/local/mysql/data/rodongi.pid:权限被拒绝

cat: /usr/local/mysql/data/rodongi.pid: Permission denied

密码:

输入密码后……

用法:杀死[-s signal_name] pid ... 杀死-l [exit_status] 杀死-signal_name pid ... kill -signal_number pid ...

usage: kill [-s signal_name] pid ... kill -l [exit_status] kill -signal_name pid ... kill -signal_number pid ...

我不知道为什么

  • 1)即使我使用了sudo命令,我也没有权限(另一次使用sudo !!)
  • 2)为什么msql-bash无法识别mysql和mysqld命令(我也在terminal-bash中尝试过;也不起作用)

推荐答案

第一个问题

您正在尝试执行命令mysqld_safe,因此该命令应位于终端查找命令的 PATH 上. (您可以通过运行echo $PATH查看这些位置.不同的位置用冒号分隔).

First problem

You're trying to execute the command mysqld_safe, so that command should be on the PATH where the terminal looks for commands. (You can view these locations by running echo $PATH. The different locations are separated with a colon).

由于要尝试运行本地目录中的文件,因此应键入./mysqld_safe告诉外壳程序您正在提供文件的路径,否则它将在中搜索它路径. (您可以通过指定完整路径从任何位置运行文件.)

Since you're trying to run a file that is in the local directory you should type ./mysqld_safe to tell the shell that you're giving a path to file, otherwise it'll search for it in the PATH. (You can run the file from anywhere by specifying the full path).

另一种解决方案是在/usr/local/bin/中建立一个指向/usr/local/mysql/mysqld_safe`的符号链接(如果我正确理解,这是命令的路径).这样,您就可以在任何地方运行该命令,因为它位于外壳程序正在寻找的路径中.

Another solution is to make a symbolic link in /usr/local/bin/ that points to /usr/local/mysql/mysqld_safe` (which is the path to the command if I understood you correctly). That way you can run the command from anywhere because it's in the path the shell is looking for.

由反引号包围的cat命令由外壳程序 执行sudo命令执行(如果每个人都可以读取该文件,则外壳程序将执行以下内容:sudo kill 12345).

The cat command surrounded by backticks is executed by the shell before running the sudo command (If the file was readable for everyone the shell will execute something like: sudo kill 12345).

要以root身份运行cat,请运行以下命令:

To run the cat as root you should run this command:

sudo bash -c 'kill `cat /usr/local/mysql/data/rodongi.pid`'

这样,您以root身份运行bash,这又运行kill命令,从而以root身份读取rodongi.pid文件.

That way, you run bash as root, which in turn runs the kill command, and thus reads the rodongi.pid file as root.

这篇关于终端无法识别mysqld和mysql命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆