nodejs是除了浏览器之外又一个js执行环境,可以作为webserver服务器。dns解析是解析到一个远端的地址,三次握手:1、客户端询问服务器是否可用;2、服务器告诉 客户端;3、客户端知道了即将访问。http的端口的80、https的端口是443

mysql硬盘数据库访问速度相比redis要慢
mysql建表的时候需注意:pk表示所有的值不能重复;AI表示自动增加;int表示整数;varchar表示字符串;nn表示不能为空;bigint表示更大的整数;longtext不限长度的字符串(大约能存4g的大小);alertTable 表示编辑表;DropTable表示删除表
use nodeServer;
-- show tables;
-- insert into users (username, `password`, realname) values ('zhangsan', '123456', '张三1');
-- select * from users;
-- select realname from users;
-- select * from users where id="2" and username="zhangsan";
-- select * from users where id="2" or username="zhangsan";
-- select * from users where username like "%san%";
-- select * from users where username like "%san%" order by id desc;accessible
-- SET SQL_SAFE_UPDATES = 0;
-- update users set realname="藤虎" where id = '1';
-- delete from users where id = '2';
-- 下面是软删除的操作,不会真的删除数据
-- select * from users where state = 1;
-- update users set state = 0 where realname ='藤虎';
-- select * from users where state <> 1; -- 代表它不等于1
-- insert into blogs (title, content, createtime, author) values ( '标题A', '内容B', 1566295596467, 'zhangsan' );
-- select * from blogs;
为了安全需要用到session,但是如果session存入几百上千个数据很可能会让进程奔溃;云服务器是多线程会跑多个进程,操作系统不允许访问各个进程中的内存,导致数据不能共享,使用redis能够解决这个问题,redis是一个缓存数据库(以key-value的方式存数据),相比mysql访问比较快,但是内存存的数据量小,成本相对高,由于session访问频繁,不用考虑断电丢失的问题,而网站数据存在redis中很可能断电后丢失(但是redis配置后也可以实现断电保护)
redis是内存数据库访问速度快,缺点:断电丢失
终端 启动redis
LIPAdeMacBook-Air:redis-test niko4$ redis-server
631:C 08 Sep 2019 14:42:10.866 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
631:C 08 Sep 2019 14:42:10.867 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=631, just started
631:C 08 Sep 2019 14:42:10.867 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 631
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
631:M 08 Sep 2019 14:42:10.886 # Server initialized
631:M 08 Sep 2019 14:42:10.886 * Ready to accept connections
终端操作 redis-cli
LIPAdeMacBook-Air:nodejs-myblog niko4$ redis-cli
127.0.0.1:6379> get *
(nil)
127.0.0.1:6379> get val
(nil)
127.0.0.1:6379>
nginx 反向代理
高性能的web服务器开源免费 可用于作静态服务器 (存一些 图片 js文件)反向代理(最常用) :遇到不同的请求去不同的服务器去获取。
- 启动: nginx
- 修改配置文件 sudo vi /usr/local/etc/nginx/nginx.conf
- 退出编辑:esc; :wq 退出配置文件
- nginx -t 测试配置文件是否正确
- nginx -s reload 修改后重启
- 退出:nginx -s stop
243

被折叠的 条评论
为什么被折叠?



