We can install MySQL server using Homebrew on any Computer which is running Apple M1/M2 chip.
First, we need have a Homebrew installed on your system and then we can install MySQL server Homebrew
brew install mysql
Set Root Password*
I would suggest setting root password unless you are 100% sure that you are not going to store any sensitive/secrete information.
mysqladmin -u root password 'your-password-for-root-user'
Start MySQL using Brew Services
the following command will ensure that the MySQL server will start on each restart of your computer. if you do not want to start it manually.
brew services start mysql
If you do not want to start MySQL automatically, first you need to stop the MySQL brew service:
brew services stop mysql
Now you can Start of stop MySQL Server use following commands:
Login to MySQL Server with Password
mysql -u root -p
Login to MySQL Server without Password
mysql -u root
You can also use the GUI to access MySQL such as MySQL Workbench, Sequel Pro or the TablePlus