How to get the data directory of MySQL

Submitted by Jochus on Thu, 07/03/2013 - 19:30 | Posted in: Database


I manually installed MySQL on my Macbook Pro, but I didn't know where MySQL stores its data by default (it's not defined in /etc/my.cnf). You can ask this to MySQL using the following query:

SHOW VARIABLES LIKE 'datadir';

This will result in something like this:

+---------------+----------------------+
| Variable_name | VALUE                |
+---------------+----------------------+
| datadir       | /var/lib/mysql/DATA/ |
+---------------+----------------------+
1 ROW IN SET (0.00 sec)

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.