How to find the mysql data directory from command

2019-01-20 22:02发布

In linux I could find the mysql installation directory with the command which mysql. But I could not find any in windows. I tried echo %path% and it resulted many paths along with path to mysql bin.

I wanted to find the mysql data directory from command line in windows for use in batch program. I would also like to find mysql data directory from linux command line. Is it possible? or how can we do that?

In my case, the mysql data directory is on the installation folder i.e. ..MYSQL\mysql server 5\data It might be installed on any drive however. I want to get it returned from the command line.

8条回答
forever°为你锁心
2楼-- · 2019-01-20 22:37

Check if the Data directory is in "C:\ProgramData\MySQL\MySQL Server 5.7\Data". This is where it is on my computer. Someone might find this helpful.

查看更多
仙女界的扛把子
3楼-- · 2019-01-20 22:48

You can try this-

mysql> select @@datadir;

PS- It works on every platform.

查看更多
登录 后发表回答