Setting Up MySQL on macOS via Installer and Homebrew
Deploying via Official DMG Archive
Retrieve the latest Comunity Server build from the official distribution portal. During the setup wizard, explicitly select Legacy Password Encryption when prompted for the root credential to ensure backward compatibility with older client utilities.
Resolving PATH Limitations
Executing client commands direct in the terminal may trigger a command not found error because the executable resides outside standard system directories. Resolve this by creating a symbolic link to expose the binary globally:
MYSQL_BIN_DIR="/usr/local/mysql/bin"
cd /usr/local/bin
ln -sf "${MYSQL_BIN_DIR}/mysql" .
ln -sf "${MYSQL_BIN_DIR}/mysqld" .
ln -sf "${MYSQL_BIN_DIR}/mysqladmin" .
Updating Authentication Protocol
Modern releases enforce caching_sha2_password as the default authentication mechanism. Many third-party ORMs and GUI clients still require the traditional plugin. Switch the administrative account back to legacy encryption:
ALTER USER 'root'@'localhost'
IDENTIFIED WITH mysql_native_password BY 'YourSecurePassword';
FLUSH PRIVILEGES;
Deploying via Homebrew
Package Acquisition & Service Control Utilize the package manager to fetch and configure the server:
brew install mysql
Manage background processes through native service managers:
# Launch daemon
brew services start mysql
# Terminate daemon
brew services stop mysql
Security Hardening Execute the built-in security script to apply production-ready constraints:
mysql_secure_installation
The utility presents an interactive prompt chain:
- Decline the password validation module to bypass minimum length requirements.
- Define a robust administrative credential when requested.
- Confirm deletion of anonymous accounts (
y). - Restrict remote root access (
yrestricts to localhost only; adjust based on network topology). - Eliminate the default sample database (
y). - Apply privilege grants immediately (
y).
Operational Verification Validate connectivity and monitor process lifecycle:
# Authenticate session
mysql -u root -p
# Check active threads
ps aux | grep mysqld | grep -v grep
# Review service state
brew services list | grep mysql