-1

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

mysql>

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/
shantanuo
  • 3,579
  • 8
  • 49
  • 66
  • 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 03 '13 at 09: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 03 '13 at 09: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 03 '13 at 09:55

1 Answers1

3

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...

Alexis Wilke
  • 2,210
  • 1
  • 20
  • 37