Download, installation and detailed configuration of Mysql in MAC environment

This article mainly introduces how to download and install mysql on MAC and configure the terminal environment.

1. Download the installation package

Network disk download: https://pan.baidu.com/s/1xxCE9-7ErAc6_U4QA_vFIA Password: ep84

Official website download: https://dev.mysql.com/downloads/mysql/
Insert image description here

2. Double-click the downloaded installation package (.pkg file)

Insert image description here
Insert image description here
Keep clicking Continue. When the password setting interface appears midway, set and remember the password. This password is the root password for logging in to mysql.
Insert image description here

4. After installation, open the system preferences and you will see the mysql icon.

Insert image description here
Double-click to open and you will see the following page, which generally does not need to be modified.
Insert image description here

5. Configure mysql in the terminal environment

1) Before configuration , enter in the terminal mysqland find the following content, indicating that the terminal environment has not yet configured mysql.
Insert image description here

2) Check whether mysql is installed , enter in the terminal: ls -al /usr/local/mysql/bin
Insert image description here
3) Add the environment path: (the following shows the zsh environment)
a. Open the file: open ~/.zshrc
b. Add the statement: PATH=$PATH:/usr/local/mysql/bin, and then save
c. Make the configured statement effective: source ~/.zshrc
Insert image description here
if it is a bash environment , the above abc steps are:
a. Open the file: open ~/.bash_profile
b. Add statements: PATH=$PATH:/usr/local/mysql/bin
c. Make the configured statements take effect:source ~/.bash_profile

( Note : All the above steps a and b can also be edited through vim. zshrc or .bash_profile file)

4) The terminal environment is configured successfully . Enter: in the terminal and mysqlyou can see the following information:
Insert image description here
5) Log in and use mysql . Enter: mysql -uroot -p, then enter the login password (root password) set during installation. After successful login, you can use mysql normally
Insert image description here
. , mysql has been successfully installed!

6. The following introduces several common database operation syntaxes:

Simple operation of the database:

(1) Create database: create database 数据库名称;
(2) View database: show databases;
(3) Open database: use 数据库名称;
(4) Delete database:drop database 数据库名称;
Insert image description here

Add, delete, and modify tables:
(1) Query data: select * from 表名 where 字段 = 值;
(2) Insert data: insert into 表名 (字段1, ……) values (值1, ……);
(3) Update data: update 表名 字段=值,…,字段n=值n where 字段=值;
(4) Delete data:delete from 表名 where 字段=值;
Insert image description here

Guess you like

Origin blog.csdn.net/ganyingxie123456/article/details/112510521