Skip to content

数据库基础

MySQL基本语句

docker run -d -p 3307:3306 --name mysql5.7 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
ssh连接MySQL数据库
mysql -uroot -p123456
登陆 MySQL 服务后,使用create命令创建数据库

CREATE DATABASE test;

选择指定数据库 use DATABASE;

use test;

创建数据表 CREATE TABLE table_name (column_name column_type);

CREATE TABLE users (
    `id` INT UNSIGNED AUTO_INCREMENT,
    `username` VARCHAR(100) NOT NULL, 
    `password` VARCHAR(100) NOT NULL, 
    PRIMARY KEY ( `id` )
);

插入数据

INSERT INTO users (id,username,password) VALUES (1,"admin","1234567890");

Redis

部署

docker run -d --name redis -p 6379:6379 redis

postgreSql

部署

docker run --name postgres -e POSTGRES_PASSWORD=123456 -p 5432:5432 -d postgres docker exec -it 381 bash

基本语句

进入PostgreSql psql -U postgres

创建数据库 CREATE DATABASE DB1;

查看数据库

\l

切换数据库

\c db1

新建表 create table ffffflllllaaaaagggggg(dkkk CHAR(50));

查看当前数据库存在的表

\d

查看表格信息 \d tablename

插入数据 insert into ffffflllllaaaaagggggg values ('flag{testtesttesttest}');

查询 select * from ffffflllllaaaaagggggg;

CREATE DATABASE fl4g;
\c fl4g;
create table ffffflllllaaaaagggggg(dkkk CHAR(50));
insert into ffffflllllaaaaagggggg values ('flag{testtesttesttest}');

CREATE DATABASE hint;
\c hint;
create table hint(username CHAR(5),ssrf CHAR(50));
insert into hint values ('admin','ffffffllllll444444gg_ssrf.php');
insert into hint values ('aaest','hacker.php');