前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >“my12306”项目日报(一)

“my12306”项目日报(一)

作者头像
看、未来
发布2021-11-09 16:38:22
4520
发布2021-11-09 16:38:22
举报
文章被收录于专栏:CSDN搜“看,未来”

文章目录

项目设计图

这个版本预计会在双十一之前完成,所以时间也不算很赶,也不算很长,画甘特图啥的就没意思了。

昨天先是写了两篇博客,一篇是:“我是怎么写项目的”,一篇是:“我的毕设实战指南”。

然后选用了Ubuntu系统,安装了一系列基础环境,及MySQL。

MySQL的安装我这里简单说一下,其实很简单,现在在Linux系统上安装软件越来越简单了,不像我初学的时候安装个软件要一早上。


Ubuntu 上 MySQL安装

1)首先检查系统中是否已经安装了MySQL

在终端里面输入 sudo netstat -tap | grep mysql,若没有反应,没有显示已安装结果,则没有安装。

当然,新系统里面连 netstat 都没有。

那就安装netstat:sudo apt-get install net-tools

这时候需要 root 权限,如果忘记 root 密码,或者压根儿就没有设置 root 密码,也好办:

输入sudo passwd root,可以看到提示Enter new UNIX password,此时输入我们想要设置的密码。

回车后,又看到Retype new UNIX password,再次输入密码进行确认。

回车后可以看到password updated successfully,即密码修改成功提示。

再次su root,输入密码,可以看到终于能够使用root进行登录了。

如果再遇到:

代码语言:javascript
复制
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1446 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

这种问题,那人家进程号都给你了,直接 kill 掉就好。


当这些外部因素都处理完之后,安装MySQL就很顺畅了。

代码语言:javascript
复制
sudo apt-get install mysql-server mysql-client

速度也是极快的。

可通过登录MySQL测试,在终端输入 mysql -uroot -p 接下来会提示你输入密码,输入正确密码,即可进入。密码就是没密码,回车就好。


MySQL的一些简单管理:

启动MySQL服务: sudo start mysql

停止MySQL服务: sudo stop mysql

其他:

一、启动方式

1、使用 service 启动:service mysqld start

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

3、使用 safe_mysqld 启动:safe_mysqld&

二、停止

1、使用 service 启动:service mysqld stop

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld stop

3、mysqladmin shutdown

三、重启

1、使用 service 启动:service mysqld restart

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld restart


数据库设计

安装完MySQL,自然就开始设计数据库了。

这里就不多说了,直接放码吧:

代码语言:javascript
复制
-- 用户账号密码表
create table User(
  id char(8) primary key, --用户id
  pwd char(8) not null,   --用户密码
  money smallint,         --账户余额
  loginstate tinyint      --登录状态
);

insert into User values('风吹蛋蛋凉','虾扯蛋',1000000000,false);
insert into User values("12345678", "12345678", 0);


--以下这些车票情况是需要放到缓存中的
-- 普通车厢车票情况表
create table comPick(
  cid char(8),                      --车次
  startaddr char(8) not null,       --出发地
  arriveaddr char(8) not null,      --目的地
  startday date,                    --日期(一次性可设置一个月的量)
  starttime time,                   --发车时间
  arrivetime time not null,         --到达时间
  comprice smallint not null,       --普通车厢票价
  comA smallint default 0,          --A号坐分配到的位置,一个车厢共20排,共15节车厢
  comB smallint default 0,          --B号坐分配到的位置
  comC smallint default 0,          --C号坐分配到的位置
  comD smallint default 0,          --D号坐分配到的位置
  comE smallint default 0,          --E号坐分配到的位置
  comstate tinyint default 0,       --是否可选坐
  primary key(cid,startday,starttime)
);



-- 一等车厢
create table spPick(
  cid char(8),        
  startaddr char(8) not null,  
  arriveaddr char(8) not null,  
  startday date,  
  starttime time,  
  arrivetime time not null,  
  spprice smallint not null,
  spA smallint default 0,  
  spB smallint default 0,   
  spC smallint default 0, 
  spD smallint default 0,   
  spE smallint default 0, 
  spstate tinyint default 0,
  primary key(cid,startday,starttime)
);


-- 站票
create table standPick(
  cid char(8),        
  startaddr char(8) not null,  
  arriveaddr char(8) not null,  
  startday date,  
  starttime time,  
  arrivetime time not null,  
  standprice smallint not null,  
  standsite tinyint default 0,
  primary key(cid,startday,starttime)
);

create index pick3 on standPick(startday,startaddr,arriveaddr);
create index pick2 on spPick(startday,startaddr,arriveaddr);
create index pick1 on comPick(startday,startaddr,arriveaddr);


-- 用户订票信息表
create table UserPick(
  id char(8),                                                
  cid char(8) not null,  
  startaddr char(8) not null,  
  arriveaddr char(8) not null,  
  startday date,  
  starttime time,    
  arrivetime time not null, 
  price smallint not null,  
  paystate tinyint default 0,   --支付状态
  primary key(id,startday,starttime),  
  foreign key(id) references User(id),  
  foreign key(cid) references standPick(cid)
);

多多少少还是有缺漏在里面的,毕竟我MySQL也不是用的很六。


整完这些就挺晚的了,毕竟白天都在画图,以及约朋友了。

于是顺手再给Ubuntu配置了一下github,以及给VScode配置连接,毕竟git下载的速度简直了。。。


VScode 连接 Ubuntu

1、检查虚拟是否安装了ssh服务端:输入sudo ps -e |grep ssh

如果只有这个说明还没安装。

代码语言:javascript
复制
sudo apt-get install openssh-server

再测,如果多出一行说明安装好了。

在虚拟机终端,通过连接主机可以试验是否ssh可以正常使用:ssh localhost

如果报错(其实不是报错,是让你输入密码,但是根本就还没有设置密码,哪儿来的密码?):

代码语言:javascript
复制
cd ~/.ssh/                     # 若没有该目录,请先执行一次ssh localhost
ssh-keygen -t rsa              # 会有提示,都按回车就可以,或者也可以自己输入密码
cat ./id_rsa.pub >> ./authorized_keys  # 加入授权

VScode那边的配置我就不多说了吧:

代码语言:javascript
复制
Host localhost
    HostName 192.168.190.130
    User wlf

Ubuntu 配置 github

代码语言:javascript
复制
用‘git’指令进行查看是否安装
sudo apt-get install git
git config --global user.name "xxxx"
git config --global user.email "xxxxx@xxx.com"
ssh-keygen -C "your email@xxx.com" -t rsa
cd ~/.ssh
gedit id_rsa.pub 
打开id_rsa.pub文件然后进入github网站,在SSH处输入id_rsa.pub文件中的所有内容即可
ssh -T git@github.com 测试链接是否通畅

如果说找不到 .git 文件夹,git init 一下就好。

带图流程可以看:

Github 与 Git,新手初次接触的尴尬历程


本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/11/04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 项目设计图
  • Ubuntu 上 MySQL安装
    • MySQL的一些简单管理:
    • 数据库设计
    • VScode 连接 Ubuntu
    • Ubuntu 配置 github
    相关产品与服务
    云数据库 MySQL
    腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档