MySQL

1. Connect to the mysql console:

# mysql -p

2. Look the value of ‘datadir’ variable to find the location of database files:

mysql> SHOW VARIABLES WHERE Variable_Name = 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.00 sec)

PostgreSQL

1. Connect to postgresql console:

# psql -U postgres

2. Show the value of ‘data_directory’

postgres=# show data_directory;
data_directory
------------------------------
/var/lib/postgresql/9.1/main
(1 row) 
Share!