2

I am working with a Redhat distribution. The network admin is inaccessible so I have no ability to request information.

Using bash, how do I find the mysql binary so that I can run sql commands?

mysql -u user -p password
-bash: mysql: command not found

So they did not set up the path.

Roy Hinkley
  • 527
  • 4
  • 13
  • 20

4 Answers4

4

It usually should be in the path already and can be executed with just calling mysql in the shell.

If that's not working (and you have reason to expect the mysql CLI binary to be installed), you can try to find it with find:

 find / -name mysql -type f

Example:

find / -name mysql -type f
/usr/bin/mysql
Sven
  • 98,649
  • 14
  • 180
  • 226
1

MySQL consists of two components, the MySQL server which is the actual database engine and the MySQL client, used to communicate with the database server from the command line.

The MySQL client is installed from the plain mysql software package. If it isn't available (check with rpm -q mysql) use yum install mysql after which the mysql command should available in your regular path or by it's default absolute path /usr/bin/mysql.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
0

Run the following command:

which mysql

Example where no MySQL binary is installed:

cwatson@thor:~$ which mysql
cwatson@thor:~$ 

Examlple where MySQL binary is installed to /usr/bin/mysql:

cwatson@cwatson-desktop ~/Desktop $ which mysql
/usr/bin/mysql
cwatson@cwatson-desktop ~/Desktop $ 

Typically though, if just running mysql from the command line results in "comamnd not found", then the binary is not in your user's PATH, or is not installed at all.

Craig Watson
  • 9,575
  • 3
  • 32
  • 47
0

Verify that the mysql package is installed, e.g.,:

rpm -qi mysql

or rpm -qa |grep mysql

Note that the server itself is packaged as mysql-server.

If it's not installed, you will need to install the client, though this will require root privileges to do so:

yum install mysql
cjc
  • 24,916
  • 3
  • 51
  • 70