I. Download and Installation
First go to the official website to download the Mac version of MySQL, the suffix of the. DMG Package
: https://dev.mysql.com/downloads/mysql/
After downloading, a step-by-step fool installation, after installation, MySQL will pop up a box to tell you the installation and root user initial password, note that the MySQL for Mac initial password is randomly generated, it is best to remember
Two. Change the initial password
A. Open the terminal
1. Go to the MySQL Bin directory (the default installed directory is/usr/local/mysql/bin)
cd /usr/local/mysql/bin/
2. Enter the instruction and prompt for the password (enter the root password of the Mac account)
sudo./mysqld_safe--skip-grant-tables
3. After entering the password, you will find some hints, and MySQL will automatically restart
B. Open a different terminal
1. Input command 1: (go to the MySQL bin directory)
Input: cd /usr/local/mysql/bin/
2. Input Command 2:
Input: ./mysql
3. Go to MySQL command state: ( mysql>
is the MySQL command status prompt)
Input:mysql> FLUSH PRIVILEGES;
4. Set Password root
Input:mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘root‘);
At this point, the initial password setup is complete
Three. Configure Environment variables
< Span class= "Apple-converted-space" >< Span class= "Apple-converted-space" >< Span class= "Apple-converted-space" If you do not set the environment variable, the input command is too cumbersome, each login mysql command is:/usr/local/mysql/bin/mysql-u root-p
The Windows system adds the MySQL path directly to the environment variables, and the MAC system needs to create a new path path to MySQL in the. bash_profile file in the home directory.
View Home directory:
Enter command Echo $HOME
The default home directory for Mac is the current user root directory /users/silverlaw
To configure environment variables:
1. Open the terminal and enter:
Open. Bash_profile
2. Enter the following statement directly:
Export Path=${path}:/usr/local/mysql/bin
Save, close terminal and TextEdit
Re-open the terminal, enter: Mysql-u root-p, you can successfully login
Mysql for MAC installation and environment configuration