I recently walked through how to make WP-CLI globally accessible across your system (assuming you’re running macOS or a variation of Linux).

I’ve also talked about various things as it relates to using MAMP Pro for WordPress development. Naturally, one of those tools is also MySQL; however, it’s one that is often treated as a “set it and forget it” application.

But I’ve recently started working on a project that requires a bit of automation as it relates to syncing the development and the staging databases. And since this is scripted, it assumes that MySQL is globally available.

If the only way you’ve installed MySQL is via MAMP (or perhaps another similar package), then you’ll likely need to make MySQL globally accessible on your system.

Here’s how to do that.

Make MySQL Globally Accessible

There are at least two ways this can be done, and different people will prefer their method. For example, some may want to update their bash profile to specify where the executable is. Others may opt for setting a symbolic link.

Since I’ve shared how to do something similar with a bash profile in a previous post, here’s an easy way to do it via symbolic linking.

Symbolic Links

Assume that MySQL is in the following path:

/Applications/MAMP/Library/bin/mysql

Enter the following in the terminal (and then press enter):

ln -s ~/usr/local/bin/mysql /Applications/MAMP/Library/bin/mysql

This will create a symbolic link in the usr/local/bin directory that references the MySQL binary that ships with MAMP Pro.

It’s simple, and it’s similar to other things you may encounter (like syncing IDE settings), so it’s nothing fancy. But if you’re working on a project or part of a project that requires scripting that relies on the of a database, this is how you can make sure the same version of MySQL is used both with your web server and any said scripts.