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.参考项目

相关推荐
肆忆_4 小时前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
不想写代码的星星8 小时前
虚函数表:C++ 多态背后的那个男人
c++
端平入洛2 天前
delete又未完全delete
c++
端平入洛3 天前
auto有时不auto
c++
西岸行者4 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
哇哈哈20214 天前
信号量和信号
linux·c++
多恩Stone4 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
starlaky4 天前
Django入门笔记
笔记·django
勇气要爆发4 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
蜡笔小马4 天前
21.Boost.Geometry disjoint、distance、envelope、equals、expand和for_each算法接口详解
c++·算法·boost