Files location for the MySQL databases

Files location for the MySQL databases

Check with command from MySQL workbench or command window:

From MySQL Command prompt:
mysql> SELECT @@datadir
C:\ProgramData\MySQL\MySQL Server 8.0\Data\

On Windows Platform
Check the my.ini configuration file.

1) Go to the location of my.ini, which store in the MySQL installation folder.

Example C:\ProgramData\MySQL\MySQL Server 8.0\my.ini

2) Open the “my.ini” with notepad

# Path to installation directory. All paths are usually resolved relative to this.
# basedir="C:/Program Files/MySQL/MySQL Server 8.0/"

# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 8.0/Data

Note: datadir is the pointer of the location where datafiles are stored.

On Linux Platform
Check the my.cnf configuration file

1) Go to the my.cnf location with help of the find / -name my.cnf command as shown:

root@host1:~$ find / -name my.cnf
find: /home/lost+found: Permission denied
find: /lost+found: Permission denied

2) Open the my.cnf file.

yongmo@myserver:~$ cat /etc/mysql/my.cnf
# The MySQL database server configuration file.
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# * Basic Settings
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

Note: Datadir is the pointer location where data files stored.

This entry was posted in MySQL on by .

About SandeepSingh DBA

Hi, I am working in IT industry with having more than 10 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.