Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the MySQL path

I tried googling to get the MySql path, but it was unsuccessful. Is there a unix command, where I can find the MySQL database directory path?

like image 604
AlwaysALearner Avatar asked Dec 10 '12 07:12

AlwaysALearner


2 Answers

Try this query,

SHOW VARIABLES LIKE 'datadir';

like image 156
Adem Öztaş Avatar answered Sep 25 '22 19:09

Adem Öztaş


Find the my.cnf and then find the datadir

sudo find / -name "my.cnf" | xargs cat | grep "datadir" | cut -d" " -f2

or if you know the location of the configuration file

cat /etc/mysql/my.cnf | grep "datadir" | cut -d" " -f2
like image 36
Baconator507 Avatar answered Sep 24 '22 19:09

Baconator507