There are two ways to install MySQL on a Mac
Download the DMG package to install
- download address: https://www.mysql.com/downloads/ - scrolling to the bottom, select ` DOWNLOADS = > MySQL Community Server `Copy the code
If you do not configure environment variables, run the mysql command in the mysql installation directory. Therefore, configure environment variables. On the terminal, go to the user directory and run 'vim. bash_profile' or run 'vim ~/. Bash_profile'. Press 'I' to enter editing mode, add the following content, press 'esc' and enter ':wq' to exit and save. # mysql export PATH=${PATH}:/usr/local/mysql/bin You can use the alias command alias mysqlstart='sudo /usr/local/mysql.support-files /mysql.server start' alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop' 'we can run mysql commands anywhere. - Terminal type 'myqsl -u root -p' to start MySQL, installation address is' /usr/local/mysql 'Copy the code
Install MySQL using Homebrew (recommended)
Install command
```
brew install mysql
```
Copy the code
mysql_secure_installation
mysql_secure_installation: [ERROR] unknown variable ‘default-character-set=utf8’.
Error: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
mysql.server start
mysql_secure_installation
If you don’t want to set a complicated password, you can start the service with an empty password (enter)
- To view the mysql initial password policy, enter the statement
SHOW VARIABLES LIKE 'validate_password%';
To view the
validate_password.policy
SET GLOBAL validate_password.policy=LOW;
validate_password_length
SET GLOBAL validate_password.length=6;
- Now you can set the simple password for MySQL, as long as it is six characters long, enter the change statement
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
If the password policy is successfully modified, the password policy is successfully modified. (Cannot be used at this timemysql_secure_installation
Go set the password!
Note: After the modification is successful, you’d better restart itmysql.server start