[mysql environment] summary of multiple installation methods and environment configuration of mysql

Table of contents

The first step: mysql installation method

method one:

Method Two:

Method three:

Step 2: Configure environment variables

Step 3: Verify whether the configuration is successful


The first step: mysql installation method

method one:

Download the MSI installer and install mysql

Download MySQL (official website download address https://downloads.mysql.com/archives/installer/)

(more tutorials)

like:

https://blog.csdn.net/SoloVersion/article/details/123760428


Method Two:

Download the compressed package, decompress and install

(more tutorials)

like:

https://blog.csdn.net/weixin_43605266/article/details/110477391


Method three:

Install mysql container in docker

1. Docker official website :

https://hub.docker.com/_/mysql

Order

describe

docker pull mysql

Download the latest version of Mysql image ( ===  docker pull mysql:latest )

docker pull mysql: version number

Download the specified version of Mysql image

Click Tags to view all versions, and the corresponding commands are in the back

——————

2. Download mysql image

docker pull mysql

——————

3. View the downloaded image

sudo docker images

 ——————

4. Create a Mysql container and run it

Order

describe

docker run

Create a new container and run it at the same time

-name mysql

The name of the container to start (mysql here)

-d

Background process

-p 3306:3306

Map container's 3306 (back) port to host's 3306 (front) port

-restart unless-stopped

Container restart strategy

-v /mydata/mysql/log:/var/log/mysql

Mount the log folder to the host

-v /mydata/mysql/data:/var/lib/mysql

Mount the mysql storage folder to the host

-v /mydata/mysql/conf:/etc/mysql

Mount the configuration folder to the host

-e MYSQL_ROOT_PASSWORD=root

Set root password (need to remember)

mysql: version number

Start the corresponding mysql version 

\

shell command newline

(Note: Before using -v to mount the file on the host, you need to ensure that the folder already exists)

Do not mount:

docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql

Mount (after using the unmount command, there is no need to enter it here):

docker run \
--name mysql \
-d \
-p 3306:3306 \
--restart unless-stopped \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:版本号

Note: If it is not mounted, if you want to continue to mount later, use the mount parameter -v file address parameter (that is, the above mount command)

There is no folder, we can create it manually

mkdir -p /mydata/mysql/log

——————

5. View running containers

docker ps

——————

6. Enter the mysql container (mysql is the container name)

docker exec -it mysql bash

enter mysql

mysql -uroot -p

(The place where the password is entered is hidden. It is entered but will not be displayed. Successfully entered the mysql command line)



Step 2: Configure environment variables

1. Enter the environment variable editor


2. "System Variables" ---> "Path" ---> "Edit" ---> "New" ---> Add the MySQL installation path ---> "OK"

Add the mysql bin directory

Step 3: Verify whether the configuration is successful

1、window+R--->cmd


2. Enter mysql -u root -p and press Enter (open directly on the command line provided that the global environment is configured)

Enter the password, press the Enter key, the mysql command line appears and it is successful

Guess you like

Origin blog.csdn.net/qq_53079406/article/details/131383989
Recommended