1.MySQL安装
>> sudo apt-get install mysql-server -y
>> sudo apt-get install libmysqlclient-dev -y
2.MySQL配置
>> sudo mysql
mysql> use mysql;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;
mysql> flush privileges;
mysql> exit;
mysql> create database webdb;
mysql> use webdb;
mysql> create table user(
username char(50) NULL,
passwd char(50) NULL
) engine=InnoDB;
mysql> create user 'mirror'@'localhost' identified by 'cjy';
mysql> grant all on webdb.user to 'mirror'@'localhost';
mysql> flush privileges;
3.源码下载
>> git clone https://github.com/qinguoyi/TinyWebServer.git
4.修改main.cpp
文件中user, passwd, databasename三个选项:
string user = "mirror";
string passwd = "cjy";
string databasename = "webdb";
5.编译运行TinyWebServer
项目
>> chmod +x build.sh && ./build.sh && ./server
6.运行结果查询
localhost:9006
7.参考项目