1. Download MySQL
Download on the official website MySQL
Download address: https://dev.mysql.com/downloads/mysql/
注
:The official website download may be a little slow, so I prepared the installation package of Baidu Cloud, and the articles in need will be taken by myself at the end
2. Install MySQL
After downloading the installation package, double-click to open the installation package, double-click pkg
the file, and continue to the next step according to the requirements. Mac installation is relatively easy. It should be noted that at the end, it will prompt that the installation is successful and, remember, it will 初始密码
be 保存一下
useful in the future
3. Run MySQL
- Click on the upper left corner
苹果logo
to enter系统偏好设置
- You will find the icon
MySQL
already , double-click to open
- Click
开启服务
, you will be prompted to enter the computer password, and then you will findstopped
that it becomesrunning
- Open the terminal and view
mysql
// 执行语句
ps aux | grep mysql
- Use
cd命令
to switch to this directory, and then use tols命令
view the contents of the current directory, the command is as follows:
// 执行语句
cd /usr/local/mysql
ls
6. Because we have not yet configured mysql
environment variables, we need to start mysql in the directory under the directory when we start mysql mysql
under the terminal bin
, so we also need to enter the bin directory at this time, and log in through the initial password obtained by installing mysql Operation
Note: After entering the second operation, you will be prompted to enter a password, which is invisible
// 执行语句
cd bin/
./mysql -u root -p
7. Due to the input 初始密码太复杂
, 更改
the initial password (note that in mysql, you need to add ';' at the end of the statement)
// 执行语句
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('这里放你想要设置的密码');
8. After changing the password, click 刷新
on the database
// 执行语句
FLUSH PRIVILEGES;
4. Configure environment variables
- First you need to exit mysql,
exi
just enter t
- Check if there is a .bash_profile file.
The path of the .bash_profile file under Mac is /Users/your own user directory/.bash_profile file, which is probably what I have below. If not, create one in this location
- Click to open the file, enter the following content anywhere, save and exit (
command+s
)
// 执行语句
PATH=$PATH:/usr/local/mysql/bin
4. Then you can open the terminal and enter the mysql login command to directly enter mysql
5. Test
mysql
The mysql operation can be performed normally under
6. mysql installation package (mac and win)
Link: https://pan.baidu.com/s/1GbNnwGSw5S0tINGIbatRhQ Password:z9ei