Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Figuring out absolute path of mysql to execute shell script

Tags:

shell

php

mysql

How to figure out the 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?

like image 381
Pentium10 Avatar asked Dec 05 '22 01:12

Pentium10


2 Answers

Unix/Linux: which mysql returns the path to the mysql executable

I don't know about windows.

like image 131
jigfox Avatar answered Dec 10 '22 11:12

jigfox


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!

like image 40
Softpoint Avatar answered Dec 10 '22 10:12

Softpoint