Terminal doesnt not recognise mysqld and mysql commands

前端 未结 1 847

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

After

1条回答
  •  离开以前
    2021-01-16 18:15

    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).

    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).

    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.

    Second Problem

    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).

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

    sudo bash -c 'kill `cat /usr/local/mysql/data/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.

    0 讨论(0)
提交回复
热议问题