Finding out the absolute mysql path to execute a shell script

How to determine mysql location on server (windows or linux)?

I would like to run

 mysql -u USER -p PASS DATABASE < filename.sql 

but i need an absolute mysql path, how do i know?

+4
source share
4 answers

Unix / Linux: which mysql returns path to executable mysql

I do not know about windows.

+6
source

which mysql will not return anything if it is not already in the path.

on linux you can use

updatedb locate mysql

or `find / -name" mysql "-print

Windows just uses its crappy search tool

+5
source

I wanted to do something similar and found this SQL statement: SHOW VARIABLES LIKE 'basedir'

 $result = mysql_query("SHOW VARIABLES LIKE 'basedir'"); $row = mysql_fetch_assoc($result); echo $row['Variable_name']." = ".$row['Value']; 

It will tell you the base directory of the MySQL server. Add "/ bin /" and then your command.

Enjoy it!

+4
source
 echo $_SERVER["MYSQL_HOME"]; 
-1
source

All Articles