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

相关推荐
red_redemption1 天前
自由学习记录(135)
学习
myloveasuka1 天前
Java与C++多态访问成员变量/方法 对比
java·开发语言·c++
2301_821700531 天前
C++编译期多态实现
开发语言·c++·算法
奥地利落榜美术生灬1 天前
c++ 锁相关(mutex 等)
开发语言·c++
xixihaha13241 天前
C++与FPGA协同设计
开发语言·c++·算法
小小怪7501 天前
C++中的函数式编程
开发语言·c++·算法
金山几座1 天前
C#学习记录-事件
开发语言·学习·c#
X在敲AI代码1 天前
推荐系统学习 D1推荐系统核心概述
学习·推荐算法
我的xiaodoujiao1 天前
API接口自动化测试详细图文教程学习系列1--序章
python·学习·pytest
圆弧YH1 天前
服务器及网站操作
学习