TinyWebServer学习笔记(一):WSL编译运行

1.MySQL安装

bash 复制代码
# 系统环境:Win11的WSL
# 1.安装mysql相关模块
>> sudo apt-get install mysql-server -y
>> sudo apt-get install libmysqlclient-dev -y

2.MySQL配置

bash 复制代码
# 1.进入mysql
>> sudo mysql
# 2.进入mysql数据库
mysql> use mysql;
# 3.修改root用户密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
# 4.修改远程访问
mysql> UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;
mysql> flush privileges;
mysql> exit;
# 5.创建数据库
mysql> create database webdb;
# 6.给创建的数据库创建表
mysql> use webdb;
mysql> create table user(
  username char(50) NULL,
  passwd char(50) NULL
) engine=InnoDB;
# 7.创建用户
mysql> create user 'mirror'@'localhost' identified by 'cjy';
# 8.给用户mirror表访问权限
mysql> grant all on webdb.user to 'mirror'@'localhost';
# 9.刷新系统权限,即时生效
mysql> flush privileges;

3.源码下载

bash 复制代码
>> git clone https://github.com/qinguoyi/TinyWebServer.git

4.修改main.cpp文件中user, passwd, databasename三个选项:

C++ 复制代码
string user = "mirror";
string passwd = "cjy";
string databasename = "webdb";

5.编译运行TinyWebServer项目

bash 复制代码
>> chmod +x build.sh && ./build.sh && ./server

6.运行结果查询

bash 复制代码
# 浏览器运行
localhost:9006

7.参考项目

相关推荐
tingshuo29171 天前
S001 【模板】从前缀函数到KMP应用 字符串匹配 字符串周期
笔记
blasit1 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_2 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
不想写代码的星星2 天前
虚函数表:C++ 多态背后的那个男人
c++
端平入洛4 天前
delete又未完全delete
c++
端平入洛5 天前
auto有时不auto
c++
西岸行者6 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
哇哈哈20216 天前
信号量和信号
linux·c++
多恩Stone6 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
starlaky6 天前
Django入门笔记
笔记·django