bobber205 said:
Code:
alias mysql=//usr/local/mysql/bin/mysq
When I set that alias, it works only until I exit my current Terminal session.
Why is that?
Another poster provided to solution. To your question "why is that?": by issuing the command
alias mysql=/usr/local/mysql/bin/mysql you are setting the alias for the current shell. If you want to always have an alias available then you need to ensure that the alias is set automatically when an instance of the shell starts. If you create a
.bash_profile file in your home directory then every shell command in that file will be executed automatically when a new shell starts. This means that all your aliases will be available.
By the way, it looks like you are trying to ensure that you can just type
mysql to execute
/usr/local/mysql/bin/mysql. The reason why you cannot just type
mysql to run the command without the alias being set is that the
/usr/local/mysql/bin directory is not in the list of paths that are searched to find commands to run. You can fix this by extending the path by using the following command in your
.bash_profile file:
Code:
export PATH=${PATH}:/usr/local/mysql/bin
You can check the value of the PATH environment variable using the command
set or using
echo $PATH. You can add multiple new directories to your PATH variable by separating the paths using a ":" character.
The list of folders in the PATH variable are searched in the order that they are listed. You should only add new directories to the end of the PATH variable. Adding your own directories to the start of the PATH statement opens up a moderate security risk.