0

I am reading MySQL's manuals.

They suggest me that the command

cd /usr/local/mysql
sudo ./bin/mysqld_safe          // it seems that sudo = . + master rights

is the same as

. /usr/local/mysql/bin/mysql    // only ., no master rights

Are the two commands same in action?

  • 1
    The single dot only signifies your current directory, which is why 'cd' is used with it. – Andrioid Jul 05 '09 at 09:54
  • 1
    I have added a question and answer that discusses the use of the dot and the difference between its use for sourcing a file or specifying the current directory. See http://serverfault.com/questions/36052/what-is-the-purpose-of-source-as-a-shell-command – Dennis Williamson Jul 05 '09 at 13:02

4 Answers4

5

No, those commands are completely different. You may have a typo in there -- the following two commands are equivalent:

cd /usr/local/mysql
sudo ./bin/mysqld_safe

And:

sudo /usr/local/mysql/bin/mysqld_safe
womble
  • 97,049
5
. /some/path

executes [ or includes - which is execution ] a shell script you pointed.

./some/path

[ notice lack of space after dot ] executes program/script using relative path [ from current directory, not from the top of filesystem ]

sudo executes given command with other [ usually root ] user's privileges.

there is difference between

cd /usr/local/mysql
./bin/mysqld_safe

and

/usr/local/mysql/bin/mysqld_safe

the difference is current working directory. for mysql probably that does not meter, but for other/badly written programs that use relative paths - it might meter.

pQd
  • 30,179
  • 6
  • 66
  • 110
3

From Freshmeat:

Sudo (su "do") allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments.

I'm not sure that you are confused about this, but you might be based on the question.

If you're only confused about why

cd /usr/local/mysql
./bin/mysqld_safe

Is the same as

/usr/local/mysql/bin/mysqld_safe

This is because in UNIX, the . means the current directory. So in this way, you will not search your PATH variable for the nearest mysqld_safe and run it, you will specifically run the one at /usr/local/mysql/bin/.

Kyle
  • 1,879
0

In this command:

cd /usr/local/mysql
sudo ./bin/mysqld_safe

starts the mysql server. As others have said, the period signifies the current directory. It is used in this way to, for example, override the $PATH or to execute a program that's not in $PATH. Remember, in bash, etc., the current directory is not in the $PATH unless you add "." to it (not recommended for security reasons).

Then this command allows you to access mysql:

/usr/local/mysql/bin/mysql

Note that there's no dot (".") at all in this command.

pQd
  • 30,179
  • 6
  • 66
  • 110