“This is the second day of my participation in the First Challenge 2022, for more details: First Challenge 2022”.

When I was a sophomore, I took part in a service outsourcing competition, but I failed to do anything due to my limited skills. This year, I decided to take part in it again, and the topic I chose was the banking Second kill system. I plan to record the project while writing it. The source code for the project (backend) is posted on Github, and the front-end will be posted as soon as the project is finished:

  • Github.com/yt-King/sec…

Since it is a service outsourcing competition, more attention will be paid to visual development. The current idea is divided into three modules:

  • For ordinary users of the second kill commodity module
  • Active configuration module for administrators
  • Large screen module (data display)

Whenever it is a system there will be users, so WHEN I develop the general will start from the user system, first design the structure of the user table

The serial number Chinese name The field name Is empty The data type instructions
1 A primary key id no bigint Since the primary key
2 Uuid user_id varchar A unique id
3 The user name name varchar
4 account tel varchar Register by phone number
5 password pass_word varchar MD5 encryption
6 gender sex varchar Zero: male; 1: the female
7 birthday birth varchar
8 age age varchar
9 Id Card Number id_card varchar
10 The user types user_type varchar
11 province address varchar
12 Working state status varchar 0: normal 1: abnormal (unemployed/unemployed)
13 Whether the faithless is_black tinyint Zero: no; 1:
14 Logic to delete is_delete tinyint 0: no. 1: Yes
15 Administrator or not is_leader tinyint 0: no. 1: Yes
16 Record creation time gmt_create datetime
17 Record update time gmt_modified datetime

The type of user (user_type) can be determined according to specific requirements. I have divided it into ten categories, with the default being individuals

① Enterprise legal person;

② Enterprise legal person internal unit accounting unit

The financial department that manages budgetary funds and extrabudgetary funds

(4) administrative organs and institutions that implement financial management;

(5) military and armed police units at or above the county level;

⑥ Foreign institutions in China;

⑦ Social groups;

⑧ units attached to the canteen, guest house, kindergarten;

⑨ Permanent establishment in other countries;

⑩ Private enterprises, self-employed contractors and individuals. (Default value)

The database uses mysql, version 5.7, because it is just a test, so I directly use docker to deploy a mysql (if only a local test with a local database can also be), have to say that Docker is really fragrant, learn to configure the server environment after docker is really very comfortable. If you don’t know Docker, take a look at my article: How to use Docker

Let’s start by pulling the official mysql5.7 image

Docker pull mysql: 5.7Copy the code

Create a mysql mapping directory locally

mkdir -p /home/mysql/data /home/mysql/logs /home/mysql/conf
Copy the code

/home/ mysql.conf/my.cnf/my.cnf

touch my.cnf
Copy the code

Create containers, mount data, and set parameters

docker run -p 3306:3306 --name mysql -v /home/mysql/conf:/etc/mysql/conf.d -v /home/mysql/logs:/logs -v / home/mysql/data: / var/lib/mysql - e MYSQL_ROOT_PASSWORD = "your password" - d mysql: 5.7Copy the code

The effects of some parameters are as follows

-d: indicates the background running container

-p maps container ports to local ports

-v Mounts the host directory to the container directory for local data persistence

-e Sets parameters, mainly passwords. Replace your password with your own password

Test the connection, you can see the database is ready to use, do not use the docker than words, we need to look for the corresponding the server installation package to install mysql, then configure the remote connection, a series of jumbled, with wrong unloading is very troublesome, but use the docker direct delete container and the mirror is very convenient. I still remember the bitter history of configuring various environments on the server when I just started to learn Linux, it is too painful, can only say docker, really sweet.

From here, you’re done deploying your database with Docker