[Mac os system] Install MySQL database

environment

System: Mac os intel chip

1 Download the installation package

(1) Check the chip model

uname -a | awk -F " " ‘{print $(NF-1)}’

My output root:xnu-7195.101.2~1/RELEASE_X86_64

Indicates the model of X86_64bit

(2) Download the installation package from the official website

https://dev.mysql.com/downloads/mysql/

You need to register and log in, and select the download package of the chip model, click download

insert image description here

2 Installation process

(1) Click to install

Selection: Select Use Legacy Password Encryption to install

Others can be installed by default.

Remember to enter a password before proceeding to the next step.

(2) Configuration path

First open System Preferences -> MySQL and turn it on
insert image description here

Start the MySQL service

Open a terminal and type

cd ~
touch .bash_profile
open -e .bash_profile

In the opened file type:

export PATH=${PATH}:/usr/local/mysql/bin

Then save, exit the file, close the terminal and exit.

(3) Start the MySQL command console

mysql -u root -p

will prompt for a password

(4) Authorize all permissions of the root user and set up remote access, refer to [https://javamana.com/2022/170/202206190621375814.html]

After MySQL is successfully installed, the user only supports local access by default, and cannot access remotely, and the client will report an error: 2002 - Can't connect to server on '127.0.0.1' (36)). At this time, you need to create a new remote access user for Navicat to connect to mysql. First enter the mysql command line console.

mysql -u root -p

After prompting for a password, enter the mysql command console. Relicense

GRANT ALL ON . TO ‘root’@‘’%';

If successful, return Query OK

(5) Modify password (optional)

Start Mysql first, then change the password

mysql -u root -p

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new password')

SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘1230’)

3 Problem summary

(1) Permission issue: Because it comes from an unidentified developer, it does not show that any source is allowed

insert image description here

Solution

Open a terminal and type

sudo spctl --master-disable

Close [Terminal], reopen [System Preferences] - [Security and Privacy] - [General] and select [Allow any source], so that you can install the restricted "from unknown developer" "program of.

insert image description here

(2) Installation package problem: "MySQL 8.0.31-community" cannot be installed on this computer.

insert image description here

The solution is to download the wrong chip type installation package. Go back to the first step, check the computer chip type, and select the corresponding installation package
insert image description here

Common commands

(1) Start the MySQL service

sudo /usr/local/MySQL/support-files/mysql.server start

(2) Stop the MySQL service

sudo /usr/local/mysql/support-files/mysql.server stop

(3) Restart the MySQL service

sudo /usr/local/mysql/support-files/mysql.server restart

Guess you like

Origin blog.csdn.net/weixin_43935696/article/details/127398771