Device chip and system version
1 Installation package download
Official download website: MySQL https://www.mysql.com
The first step is to enter the official website and click DOWNLOADS.
Step 2: Find the picture below on the page and click to enter.
Step 3 Select this option.
The fourth step is to select the version and download (select arm64 version for M1 chip).
2 Installation process
The first step is to download the installation package and double-click to open it
After the second step is opened
Continue>Continue>Agree>Install>Select password type (select the default strong type)>Set password (don’t forget, you will need it later)>Installation successful
After successful installation, the mysql logo will appear at the bottom of the system settings.
After clicking it, it basically defaults to the on state, and the green dot indicates the on state.
Possible problems: If mysql is in the red closed state after opening it, and automatically changes to the stop state after starting, you can check the current version of the computer system, and you may need to update the system to solve the problem.
3 configuration path
The first step is to open the terminal (open in the program dock or search "terminal" with command+space). After opening the terminal, confirm whether the current shell is bash or zsh. If you are not sure, run " chsh -s /bin/zsh " directly to change the current account's shell to zsh. Of course, you can also leave it unchanged. Then add the environment variable file.
“sudo vim .zshrc”
Enter
A password prompt appears that requires you to enter a password (the password is the unlock password for your computer) (the password is a hidden input, enter it and press Enter)
Press Enter, the vim editing window will appear
Step 2: In the open vim editing environment, press the " i " key on the keyboard and enter
" export PATH=${PATH}:/uesr/local/mysql/bin " //Note the case
Enter and press the "ESC" key, followed by " :wq "
Enter (save and exit the vim editing environment)
Note: (The input method needs to be switched to English input method, otherwise " :wq " cannot be entered correctly after pressing esc)
Possible problems: If export PATH=${PATH}:/uesr/local/mysql/bin is entered incorrectly and has been saved, you will find that export PATH=${PATH}:/uesr/ cannot be deleted after entering vim again. Wrong characters in local/mysql/bin can be deleted using the "x" key on the keyboard. If they need to be added, use the "i" key to add them.
Step 3 Input
source ~/.zshrc
Enter
Make the environment variables just set take effect
Step 4 Input
“mysql -uroot -p”
Enter
The password entered at this time is the password set during installation (if you accidentally forget it, there is a tutorial on resetting the password in the following section)
Password error prompt
The password is correct and you have successfully entered mysql.
Configuration completed
To further verify whether it is truly successful, you can close the current terminal window, reopen the terminal, and enter
“mysql -uroot -p”
See if the prompt to enter the password appears normally.
4 Password reset
The first step is to enter the system settings and click stop mysql server. If the button cannot be closed, enter the terminal and enter
“sudo /usr/local/mysql/support-files/mysql.server stop”
Step 2 Enter " cd /usr/local/mysql/bin " in the terminal
Enter
Login administrator permission input
“ sudo su ”
Enter
Step 3 Enter " ./mysqld_safe --skip-grant-tables & " to skip the mysql verification function
Enter
At this point mysql will restart.
Step 4 Enter " ./mysql "
Enter
Type " FLUSH PRIVILEGES; "
Enter
Enter " ALTER USER 'root'@'localhost' IDENTIFIED BY 'your new password'; "
Enter
Step 5: Re-open the terminal and enter " mysql -uroot -p "
Enter
Enter the changed new password to check whether you can successfully log in to mysql.