0
votes

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 being asked for the admin password, I got this error :

sudo: mysqld_safe: command not found

I wrote this in

cd /usr/local/mysql

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

I then got

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

Password:

After entering the password …

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

I have no idea why

  • 1) I dont have the permission even though I used the sudo command( and another time sudo!! )
  • 2) Why msql-bash doesn't not recognise the mysql and mysqld command ( I also tried in terminal-bash;does not work either)
1
Use which mysql to check if you have installed MySQL on your Mac.Dez
I do have mysql installed. I even can launch a mysql server but cant access MySQLWorkbench, because I need the orrt passowrd. Anyway I tried it in terminal-bash and in mysql-bash, and got no response. rodongi$ which mysql rodongi$Falanpin
If in terminal bash which mysql doesn't return any result how do you know you have mysql installed?Dez
I got MySQL in System Preferences :)Falanpin
type -a mysql should show where it is installed. What does it return?Dez

1 Answers

0
votes

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.