[笔记] TinyWebServer编译及demo运行过程

文章目录


前言

哎 也就帮帮新手看看问题 没想到一遍就顺利弄好 把我整蒙了

环境搭建

ubuntu

ubuntu-22.04.5-desktop-amd64

mysql 8.0

bash 复制代码
sudo apt install -y mysql-server

mysql 执行命令改密码,创建数据库test,和user表 插入用户和密码:

bash 复制代码
sudo mysqld -uroot # 第一次安装mysql8.0不需要密码 直接回车

创建表啥的跟这个官网新手教程一样

https://github.com/qinguoyi/TinyWebServer

bash 复制代码
// 建立yourdb库
create database yourdb;

// 创建user表
USE yourdb;
CREATE TABLE user(
    username char(50) NULL,
    passwd char(50) NULL
)ENGINE=InnoDB;

// 添加数据
INSERT INTO user(username, passwd) VALUES('name', 'passwd');

c/c++

bash 复制代码
sudo apt install make gcc g++

开启root用户

bash 复制代码
sudo passwd root 

改个root密码

TinyWebServer

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

搭建及编译过程

bash 复制代码
    8  apt install git
    9  git clone https://github.com/qinguoyi/TinyWebServer.git
   10  ls
   11  sudo apt search mysql-server
   12  sudo apt install -y mysql-server
   13  ps -ef|grep mysql
   14  sudo systemctl enable mysql
   15  sudo systemctl status mysql
   16  sudo mysql -uroot -p
   17  cd TinyWebServer/
   18  ls
   19  gedit main.cpp 
   20  sh ./build.sh
   21  apt install make
   22  sh ./build.sh
   23  sudo apt install gcc g++
   24  sh ./build.sh
   29  sudo apt install libmysqlclient-dev
   30  sh ./build.sh
   31  ls
   32  ll
   33  ./server

编译过程

bash 复制代码
sh ./build.sh
./server

运行结果


常见问题

./threadpool/.../CGImysql/sql_connection_pool.h:6:10: fatal error: mysql/mysql.h: No such file or directory

mysql的依赖头文件没有找到 安装mysql动态库到系统环境就好

bash 复制代码
sudo apt install libmysqlclient-dev

./server运行后直接退出了

可能原因 没有使用root权限运行

bash 复制代码
su # 提权后在运行./server

关于博主

wx/qq:binary-monster/1113673178 (添加时注明来意,否则不予通过)

wxgzh: 二进制怪兽

CSDN:https://blog.csdn.net/qq1113673178

码云:https://gitee.com/shiver

Github: https://github.com/ShiverZm

个人博客:https://www.binary-monster.top

相关推荐
Go Work2 小时前
两个等值条件摆着,MySQL 偏要全表扫
经验分享·笔记
Oll Correct2 小时前
Adobe illustrator 案例十四:花元素标志草图绘制
笔记·ui·adobe·illustrator
每月一号准时摆烂6 小时前
服务器运维笔记(一)——使用shell编写实时查看BMC功率的脚本
运维·服务器·笔记
柳鲲鹏1 天前
内斗学概论:43、平级内斗
笔记
星恒随风1 天前
MySQL 从零入门(四):表的增删改查与基础查询详解
linux·服务器·数据库·笔记·mysql
Z21-X1 天前
云原生运维学习笔记:ECShop全链路容器化部署与Docker底层资源隔离深度剖析
运维·笔记·学习·云原生
晓梦林1 天前
BUUCTF-菜刀流量-MISC-学习笔记
笔记·学习
David猪大卫2 天前
【C++修炼】map 和 set 的使用
c语言·开发语言·数据结构·c++·经验分享·笔记·学习
星恒随风2 天前
MySQL 从零入门(三):表的约束详解
linux·服务器·数据库·笔记·mysql
Oll Correct2 天前
Adobe illustrator 案例十三:adidas标志草图绘制
笔记·ui·adobe·illustrator