Detailed explanation of mysql installation on Mac (with installation package)

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 pkgthe 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
insert image description here

3. Run MySQL

  1. Click on the upper left corner 苹果logoto enter系统偏好设置
  2. You will find the icon MySQLalready , double-click to open
    insert image description here
  3. Click 开启服务, you will be prompted to enter the computer password, and then you will find stoppedthat it becomesrunning
    insert image description here
    insert image description here
  4. Open the terminal and viewmysql
// 执行语句
ps aux | grep mysql

insert image description here

  1. Use cd命令to switch to this directory, and then use to ls命令view the contents of the current directory, the command is as follows:
// 执行语句
cd /usr/local/mysql
ls

insert image description here
6. Because we have not yet configured mysqlenvironment variables, we need to start mysql in the directory under the directory when we start mysql mysqlunder 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  

insert image description here
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('这里放你想要设置的密码');

insert image description here
8. After changing the password, click 刷新on the database

// 执行语句
FLUSH PRIVILEGES;

insert image description here

4. Configure environment variables

  1. First you need to exit mysql, exijust enter t
    insert image description here
  2. 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
    insert image description here
  3. Click to open the file, enter the following content anywhere, save and exit ( command+s)
// 执行语句
PATH=$PATH:/usr/local/mysql/bin

insert image description here
4. Then you can open the terminal and enter the mysql login command to directly enter mysql
insert image description here

5. Test

mysqlThe mysql operation can be performed normally under
insert image description here

6. mysql installation package (mac and win)

Link: https://pan.baidu.com/s/1GbNnwGSw5S0tINGIbatRhQ Password:z9ei

Guess you like

Origin blog.csdn.net/m0_48936146/article/details/127474507