0

I have a problem with the handling of the mysql command.  When I try to use mysql -uroot -p, I get an error:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

However, when I try to use ./mysql -uroot -p from /data/local/tool/mysql-5.6.21/bin, I can connect to MySQL.  So I assume that mysql and ./mysql have different meanings.

whereis mysql output:

# using new line to look easier
/usr/bin/mysql
/usr/lib64/mysql
/usr/include/mysql
/usr/share/mysql
/data/local/tool/mysql-5.6.21/bin/mysql

The problem is that when I run which mysql, the output shows /bin/mysql.

So how do I tell bash it should pick MySQL from /data/local/tool/mysql-5.6.21/bin/mysql whenever I run mysql (without ./)?

2 Answers 2

3

just move this path /data/local/tool/mysql-5.6.21/bin in the first order or before /usr/bin within your $PATH environment variable

2

Changing the path would cause any programs in the MySQL directory to become runnable as the first choice.  To handle just mysql, do

alias mysql=/data/local/tool/mysql-5.6.21/bin/mysql

or

mysql() { /data/local/tool/mysql-5.6.21/bin/mysql "$@"; }

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.