0

I have installed mysql in /usr/local/ directory. But when I try to use the server by typing mysql -u root it says '/usr/local/bin/mysql: No such file or directory'. I could understand that it looks in a different directory. But how to change it? Or should I have to install mysql in that directory? In which case, mysql installer does not allow me to change the directory as well.

1 Answers1

4

When you type a command name without a path on a Unix-like shell, the shell looks for something of that name in every directory listed in your $PATH environment variable, in order.

You can see the contents of that with

echo $PATH

They are colon-separated.

If you want to add another directory to it (such as /usr/local/bin, which you'd need in this case), have a look at this question or this one. You could also just run that binary directly by running /usr/local/bin/mysql -u root.


But this is nothing to do with the title of your question. To answer that, see the man page of mysql, which says:

  ยท   --user=user_name, -u user_name

      The MySQL user name to use when connecting to the server

In other words, that is setting the user to be root, for purposes of authenticating with the database server. Note that this doesn't necessarily have anything to do with the root Unix user.

tremby
  • 9,541
  • 4
  • 55
  • 74