I'm using Homebrew to stop the service
brew services stop mysql
If you're using Homebrew, it should be located at /usr/local/Cellar/mysql/[your-version]
Go to the directory and make a backup for homebrew.mxcl.mysql.plist
and open homebrew.mxcl.mysql.plist
- either using nano or Sublime Text, doesn't matter.
Following are the default setting. All you need to do is to update the /usr/local/var/mysql
to the new path. Save the file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql/bin/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
<string>--datadir=/usr/local/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql</string>
</dict>
</plist>
Make sure to copy all files under /usr/local/var/mysql
to new directory. You may use the following command to copy the files recursively.
cp -R /usr/local/var/mysql /your/new/path
Once you are done with above steps, do start the service.
brew services start mysql
Try to connect to the database, create a new database - see either the new database created in old directory /usr/local/var/mysql
or you new path.
Trying to it gave me this error on the terminal /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist: Path had bad ownership/permissions
Load failed: 122: Path had bad ownership/permissions
Any hints to what to do?