I wanted to change the location of my SQL databases in order for them to be in my user’s home folder (that way, my databases would be portable as I travel with my user’s home folder). By default, when you install mySQL on OS X, everything is located at /usr/local/mysql and the data folder (the one containing the databases) goes to /usr/local/mysql/data.
The location of the data can be set in the my.cnf file BUT, don’t be alarmed, this file doesn’t exist on OS X by default. The server works without it and the file is for you to create if you need to change the server’s default behavior…
- Download and install mysql for OS X
- Install the preference pane. Start your server to make sure it works. Stop it again as we need to alter the configuration.
- Move your data folder where you wish to have it i.e.
1mv /usr/local/mysql/data /home/<user>/Applications/mysql/data
- Copy the file my-small.cnf in /etc and name it my.cnf
1sudo cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
- Edit this configuration file
1sudo vi /etc/my.cnf
- Change the data path : datadir=/home/<user>/…./data
Note: if you use innodb, change the innodb data location directive as well
- Launch your mysql server again, it should start normally, if not, review the steps above as something must have gone wrong