Install MySQL on MacOS 11 Big Sur

Maith Egeek
5 min readMay 31, 2021

This tutorial walks you through the steps to install MySQL 8.0.24 on macOS 11 Big Sur with the Apple chip M1.

MySQL doesn’t come pre-loaded with macOS Big Sur and needs to be dowloaded from the MySQL site.

The latest version of MySQL 8.0.24 does work with macOS 11 Big Sur.

Use the DMG Archive mysql-8.0.24-macos11-x86_64.dmg.

The package is located inside a disk image (.dmg) file that you first need to mount by double-clicking its icon in the Finder. It should then mount the image and display its contents.

Warning if you are re-installing or updating : before starting the installation, be sure to stop all running MySQL server instances by using either the MySQL Manager Application (on macOS Server), the preference pane, or mysqladmin shutdown on the terminal command line.

To install MySQL using the package installer:

  1. Download the disk image (.dmg) file (the community version is available here) that contains the MySQL package installer. Double-click the file to mount the disk image and see its contents.
  • Double-click the MySQL installer package from the disk. It is named according to the version of MySQL you have downloaded. For example, for MySQL server 8.0.24 it might be named mysql-8.0.24-macos11-x86_64.pkg. It first shows a warning asking for permission to run a program to determine if the software can be installed. Click on Allow.
  • The initial wizard introduction screen references the MySQL server version to install. Click Continue to begin the installation. The MySQL community edition shows a copy of the relevant GNU General Public License. Click Continue and then Agree to continue.
  • From the Installation Type page you can either click Install to execute the installation wizard using all defaults, click Customize to alter which components to install (MySQL server, MySQL Test, Preference Pane, Launchd Support — all but MySQL Test are enabled by default).

Note: Although the Change Install Location option is visible, the installation location cannot be changed.

MySQL Package Installer Wizard: Installation Type and Location
  • Click Install to install MySQL Server. The installation process ends here if upgrading a current MySQL Server installation, otherwise follow the wizard’s additional configuration steps for your new MySQL Server installation.
  • After a successful new MySQL Server installation, complete the configuration steps by choosing the default encryption type for passwords, define the root password, and also enable (or disable) MySQL server at startup.
  • The default MySQL 8.0 password mechanism is caching_sha2_password (Strong), and this step allows you to change it to mysql_native_password (Legacy).

Choosing the legacy password mechanism alters the generated launchd file to set --default_authentication_plugin=mysql_native_password under ProgramArguments. Choosing strong password encryption does not set --default_authentication_plugin because the default MySQL Server value is used, which is caching_sha2_password. If you intend on using a GUI wrapper like phpMyAdmin, you should choose "Use Legacy Password Encryption"

MySQL Package Installer Wizard: Choose a Password Encryption Type
  • Define a password for the root user, and also toggle whether MySQL Server should start after the configuration step is complete.
  1. MySQL Package Installer Wizard: Define Root Password
  • Summary is the final step and references a successful and complete MySQL Server installation. Close the wizard.

MySQL Package Installer Wizard: Summary

  • Check that the 2002 MySQL Socket error is fixed : check that /var/mysql/mysql.sock links to /tmp/mysql.sock. Otherwise, type the terminal commands :
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

MySQL server is now installed in /usr/local/mysql/bin.

Using MySQL

Using MySQL with the GUI in System Preferences

You can access its configuration panel in System Preferences > MySQL

In the menu Instances , select on the left pane MySQL 8.0,24. Click on Start MySQL Server to start the server. It will turn on a green light to indicate it is active. You can select “Start MySQL when your computer starts up” to start up mysql every time your computer reboots.

MySQL through the terminal

MySQL is installed in folder /usr/local/mysql/bin.

You can add to your bash profile (file ~/.bash_profile) the following line :

export PATH="/usr/local/mysql/bin:$PATH"

To reload the shell for the new profile to be taken into account, type the terminal command :

source ~/.bash_profile

Now you can use mysql with the command

mysql -u root -p

and type in the password you chose at installation

If you did not edit the bash profile, you can type the command

/usr/local/mysql/bin/mysql -u root -p

To exit the mysql program, type in :

exit

Troubleshooting :

At some point, I tried to select in System Preferences > MySQL > Configuration, “A configuration file”. But then I could not unselect and come back to the previous setting (it keeps on selecting back the configuration file option). Moreover, the mysql server would not start. I had to uninstall and re-install MySQL.

There are a few tutorials using homebrew but it seems it is not yet available on the apple chip M1.

References

--

--