When-ever I need to start mysql from command line, I need to cd to the base directory and then use mysql command as shown below:

# cd /home/ec2-user/percona-5.5.30-tokudb-7.0.1-fedora-x86_64/

# ./bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3


How do I start mysql simply by typing "mysql" at command prompt? I tried to export the path but it did not work.

export path=$PATH:/home/ec2-user/percona-5.5.30-tokudb-7.0.1-fedora-x86_64/bin/
  • 1
    Linux environment variables are case sensitive. So you need PATH=$PATH:/home/ec2-user/percona-5.5.30-tokudb-7.0.1-fedora-x86_64/bin – Michael Suelmann Nov 3 '13 at 9:39
  • Thanks. This is working. How do I make this path permanent? Last time when I added it to bashrc file I was locked out of server. :) Is adding it to profile much better? – shantanuo Nov 3 '13 at 9:44
  • .bashrc might get executed multiple times, so that the additional directory gets added multiple times. So .bash_profile is perhaps a better place. But that shouldn't have locked you out if the command was correct. Perhaps it contained a syntax error. Better log in while you still have your old connection running, so you can fix errors. – Michael Suelmann Nov 3 '13 at 9:55

The easiest way in your case is to use an alias.

alias mysql='(cd /home/ec2-user/...; bin/mysql)'

The parenthesis are important. They create a sub-shell so the alias does not 'cd' you to that other directory.

Note that you may want to consider using a different name than "mysql" for the alias, although it is legal, it could cause headaches later...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.