As I would like to move those files from one server to another server, while the database is offline.
8 Answers
It should be stored in: /usr/local/mysql/data

- 1,986
- 13
- 28
-
Just as a note, this is where it was stored when I installed MySQL using their actual GUI installer rather than via Homebrew. There are quite a lot of different ways of installing it! – Matt Fletcher Aug 10 '16 at 08:27
On macOS Monterey v. 12.6, mysql v. 8.0.31 - installed via with Homebrew 3.6.7 - keeps its databases under /opt/homebrew/var/mysql
.

- 111
- 1
OS X Server (at least v10.6) keeps the database in /var/mysql by default. You can change this in Server Admin -> MySQL service -> Settings -> Database location (note that editing this field doesn't actually move the data, just changes where it's loaded from).

- 11,216
- 4
- 28
- 33
With respect to a Homebrew installed MySQL (in my case its v5.7 which is not the latest default of version 8) on Mac Catalina, the following applies (at least for a keg):
- The default config file is here: /usr/local/etc/my.cnf
- The default loc for the db is here: /usr/local/var/mysql
When starting the server, you have some options to do it:
- Use the brew startup: brew services start mysql
- Or, that's equivalent to: /usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
If you're using a specific version of mysql (in my case I'm using v5.7 and thus its a keg-only install), the service name is mysql@5.7 and the bin path is /usr/local/opt/mysql@5.7

- 3
- 1
I don't have access to my Mac right now, so can't say for certain. Why not simply search (from Terminal, not Spotlight) the file system for "mysql", as there will always be a table named mysql.

- 109,363
- 18
- 175
- 245

- 27,458
- 12
- 55
- 109
Look for the my.cnf file - should be in the /etc/ directory and then look for a line like:
datadir=/var/lib/mysql
The datadir is where mysql stores all the database files.
Autobyte

- 171
- 3
- 8
If you've installed MySQL by running MAMP on the Mac, then the files are stored at /Applications/MAMP/db/mysql
For MAMP Pro, the files should be in /Library/Application Support/appsolute/MAMP PRO/db/mysql
Stack Overflow answer that addresses MAMP / Sequel Pro installations here: https://stackoverflow.com/questions/7341897/where-does-sequel-pro-mamp-store-local-databases