Figuring out absolute path of mysql to execute shell script
How to figure out the 开发者_JAVA百科mysql
location on a server (windows or linux)?
I would like to run
mysql -u USER -p PASS DATABASE < filename.sql
but I need the absolute path to mysql, how do I find out?
Unix/Linux: which mysql
returns the path to the mysql
executable
I don't know about windows.
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. Append "/bin/" and then your command.
Enjoy!
which mysql
wont return anything if its not already in the path.
on linux you can use
updatedb
locate mysql
or `find / -name "mysql" -print
Windows just use their crappy search tool
echo $_SERVER["MYSQL_HOME"];
精彩评论