1

I just installed mysql via homebrew and I wanted to change the location where mysql stores the databases. All the stuff I've found so far online have paths that I don't understand and don't exist on my machine (OSX 10.8).

Any help is greatly appreciated. Thanks.

2 Answers 2

4

If you have MySQL running a simple ps ax | grep mysql will yeld the process path.

Otherwise search your fs for mysqld it will take some time but will get the job done:

sudo find / -type f -name "mysqld"

A find / | grep mysql will print every file containing mysql in its name.

Use MySQLWorkbench, it has a nice GUI which lets you configure INNODBs data path and will also help you managing your instances.

Otherwise edit /etc/my.cnf (or create it if you don't have any) insert a [mysqld] section and set innodb_data_home_dir = /path/to/where/you/moved/your/data

[mysqld]
innodb_data_home_dir = /path/to/where/you/moved/your/data
Sign up to request clarification or add additional context in comments.

1 Comment

ps ax | grep mysql helped me find my datadir which is apparently /usr/local/var/mysql. If I move this folder to another location, how do I tell mysql where the new location is?
3

When started via homebrew services:

  1. Stop the server: brew services stop [email protected]
  2. Modify the plist file for your installed version, for example: /usr/local/Cellar/[email protected]/5.6.43/[email protected]
  3. Look for the --datadir=/usr/local/var/mysql key and set the value to the place you want to store your databases.
  4. Copy over files from /usr/local/var/mysql to your new location.
  5. Restart the server: brew services start [email protected]

1 Comment

Thank you, @BrettBond! This worked for me for mysql installed with brew, version 8.0.16 on macOS Mojave v. 10.14.4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.