How to find MySQL database location on your hard disk?

You can find MySQL database location on your hard disk in the following ways:

MySQL database location in Windows

1) Locate the my.ini file, which store in the MySQL installation folder.

For Example,

C:\Program Files\MySQL\MySQL Server 5.5\my.ini

2) Open the “my.ini” with notepad.

#Path to the database root
datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data/"

Find the “datadir” variable. It’s value is the MySQL database location in Windows.

MySQL database location in Linux / Mac

1) Locate the my.cnf with the find / -name my.cnf command.

$ find / -name my.cnf

2) View the my.cnf file

$ cat /etc/mysql/my.cnf


user = mysql pid-file = /var/run/mysqld/ socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp language = /usr/share/mysql/english skip-external-locking

3) Find the “datadir” variable. It’s value is MySQL database location in Linux/Mac.

You can change the value of this variable and restart the server to change MySQL database location. You will need to copy the existing database files from old to new location. Only then they will continue to work.


About Ubiq

Ubiq is a powerful dashboard & reporting platform. Build dashboards, charts & reports for your business in minutes. Try it for free!