1

At my terminal, I can't cd to the folder containing mysql and call it.

TimsMacBookAir:/ tim$ cd /Applications/MAMP/Library/bin/
TimsMacBookAir:bin tim$ mysql
-bash: mysql: command not found

If I execute the file by using the whole path, it works

TimsMacBookAir:bin tim$ /Applications/MAMP/Library/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.38 Source distribution

Why is that?

2
  • 1
    Because mysql is not in your PATH variable in which case you need the absolute path to the executable or you can cd to the directory where the executable file resides and call it like this-./mysql
    – fd0
    Commented Jun 24, 2015 at 10:34
  • Just use ./mysql or add . to you PATH which is not usually recommended.
    – oarfish
    Commented Jun 25, 2015 at 7:13

1 Answer 1

3

The current directory is usually not in the PATH variable (the variable contains all the directories where to look for an executable).

If you type echo $PATH you will see that . is not in the semicolon separated list of directories.

Not the answer you're looking for? Browse other questions tagged .