更新了部分文档
parent
eb2cb5f0fc
commit
daccf3fe9f
|
@ -57,15 +57,15 @@ yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit
|
||||||
2. 下载Python源代码并解压缩到指定目录。
|
2. 下载Python源代码并解压缩到指定目录。
|
||||||
|
|
||||||
```Shell
|
```Shell
|
||||||
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
|
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
|
||||||
xz -d Python-3.7.3.tar.xz
|
xz -d Python-3.7.6.tar.xz
|
||||||
tar -xvf Python-3.7.3.tar
|
tar -xvf Python-3.7.6.tar
|
||||||
```
|
```
|
||||||
|
|
||||||
3. 切换至Python源代码目录并执行下面的命令进行配置和安装。
|
3. 切换至Python源代码目录并执行下面的命令进行配置和安装。
|
||||||
|
|
||||||
```Shell
|
```Shell
|
||||||
cd Python-3.7.3
|
cd Python-3.7.6
|
||||||
./configure --prefix=/usr/local/python37 --enable-optimizations
|
./configure --prefix=/usr/local/python37 --enable-optimizations
|
||||||
make && make install
|
make && make install
|
||||||
```
|
```
|
||||||
|
|
|
@ -174,7 +174,7 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行
|
||||||
alter user 'root'@'localhost' identified by '123456';
|
alter user 'root'@'localhost' identified by '123456';
|
||||||
```
|
```
|
||||||
|
|
||||||
> 说明:MySQL较新的版本默认不允许使用弱口令作为用户口令,所以我们通过上面的前两条命令修改了验证用户口令的策略和口令的长度。事实上我们不应该使用弱口令,因为存在用户口令被暴力破解的风险。近年来,攻击数据库窃取数据和劫持数据库勒索比特币的事件屡见不鲜,要避免这些潜在的风险,最为重要的一点是不要让数据库服务器暴露在公网上(最好的做法是将数据库置于内网,至少要做到不向公网开放数据库服务器的访问端口),另外要保管好`root`账号的口令,应用系统需要访问数据库时,通常不使用`root`账号进行访问,而是创建其他拥有适当权限的账号来访问。
|
> **说明**:MySQL较新的版本默认不允许使用弱口令作为用户口令,所以我们通过上面的前两条命令修改了验证用户口令的策略和口令的长度。事实上我们不应该使用弱口令,因为存在用户口令被暴力破解的风险。近年来,攻击数据库窃取数据和劫持数据库勒索比特币的事件屡见不鲜,要避免这些潜在的风险,最为重要的一点是不要让数据库服务器暴露在公网上(最好的做法是将数据库置于内网,至少要做到不向公网开放数据库服务器的访问端口),另外要保管好`root`账号的口令,应用系统需要访问数据库时,通常不使用`root`账号进行访问,而是创建其他拥有适当权限的账号来访问。
|
||||||
|
|
||||||
再次使用客户端工具连接MySQL服务器时,就可以使用新设置的口令了。在实际开发中,为了方便用户操作,可以选择图形化的客户端工具来连接MySQL服务器,包括:
|
再次使用客户端工具连接MySQL服务器时,就可以使用新设置的口令了。在实际开发中,为了方便用户操作,可以选择图形化的客户端工具来连接MySQL服务器,包括:
|
||||||
|
|
||||||
|
@ -1199,7 +1199,7 @@ insert into tb_emp values
|
||||||
# 1. 创建数据库连接对象
|
# 1. 创建数据库连接对象
|
||||||
con = pymysql.connect(host='localhost', port=3306,
|
con = pymysql.connect(host='localhost', port=3306,
|
||||||
database='hrs', charset='utf8',
|
database='hrs', charset='utf8',
|
||||||
user='root', password='123456')
|
user='yourname', password='yourpass')
|
||||||
try:
|
try:
|
||||||
# 2. 通过连接对象获取游标
|
# 2. 通过连接对象获取游标
|
||||||
with con.cursor() as cursor:
|
with con.cursor() as cursor:
|
||||||
|
@ -1231,7 +1231,7 @@ insert into tb_emp values
|
||||||
no = int(input('编号: '))
|
no = int(input('编号: '))
|
||||||
con = pymysql.connect(host='localhost', port=3306,
|
con = pymysql.connect(host='localhost', port=3306,
|
||||||
database='hrs', charset='utf8',
|
database='hrs', charset='utf8',
|
||||||
user='root', password='123456',
|
user='yourname', password='yourpass',
|
||||||
autocommit=True)
|
autocommit=True)
|
||||||
try:
|
try:
|
||||||
with con.cursor() as cursor:
|
with con.cursor() as cursor:
|
||||||
|
@ -1263,7 +1263,7 @@ insert into tb_emp values
|
||||||
loc = input('所在地: ')
|
loc = input('所在地: ')
|
||||||
con = pymysql.connect(host='localhost', port=3306,
|
con = pymysql.connect(host='localhost', port=3306,
|
||||||
database='hrs', charset='utf8',
|
database='hrs', charset='utf8',
|
||||||
user='root', password='123456',
|
user='yourname', password='yourpass',
|
||||||
autocommit=True)
|
autocommit=True)
|
||||||
try:
|
try:
|
||||||
with con.cursor() as cursor:
|
with con.cursor() as cursor:
|
||||||
|
@ -1291,7 +1291,7 @@ insert into tb_emp values
|
||||||
def main():
|
def main():
|
||||||
con = pymysql.connect(host='localhost', port=3306,
|
con = pymysql.connect(host='localhost', port=3306,
|
||||||
database='hrs', charset='utf8',
|
database='hrs', charset='utf8',
|
||||||
user='root', password='123456')
|
user='yourname', password='yourpass')
|
||||||
try:
|
try:
|
||||||
with con.cursor(cursor=DictCursor) as cursor:
|
with con.cursor(cursor=DictCursor) as cursor:
|
||||||
cursor.execute('select dno as no, dname as name, dloc as loc from tb_dept')
|
cursor.execute('select dno as no, dname as name, dloc as loc from tb_dept')
|
||||||
|
@ -1334,7 +1334,7 @@ insert into tb_emp values
|
||||||
size = int(input('大小: '))
|
size = int(input('大小: '))
|
||||||
con = pymysql.connect(host='localhost', port=3306,
|
con = pymysql.connect(host='localhost', port=3306,
|
||||||
database='hrs', charset='utf8',
|
database='hrs', charset='utf8',
|
||||||
user='root', password='123456')
|
user='yourname', password='yourpass')
|
||||||
try:
|
try:
|
||||||
with con.cursor() as cursor:
|
with con.cursor() as cursor:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
|
|
|
@ -107,7 +107,7 @@ redis-server
|
||||||
方式一:通过参数指定认证口令和AOF持久化方式。
|
方式一:通过参数指定认证口令和AOF持久化方式。
|
||||||
|
|
||||||
```Shell
|
```Shell
|
||||||
redis-server --requirepass 1qaz2wsx --appendonly yes
|
redis-server --requirepass yourpass --appendonly yes
|
||||||
```
|
```
|
||||||
|
|
||||||
方式二:通过指定的配置文件来修改Redis的配置。
|
方式二:通过指定的配置文件来修改Redis的配置。
|
||||||
|
@ -119,7 +119,7 @@ redis-server /root/redis-5.0.4/redis.conf
|
||||||
下面我们使用第一种方式来启动Redis并将其置于后台运行,将Redis产生的输出重定向到名为redis.log的文件中。
|
下面我们使用第一种方式来启动Redis并将其置于后台运行,将Redis产生的输出重定向到名为redis.log的文件中。
|
||||||
|
|
||||||
```Shell
|
```Shell
|
||||||
redis-server --requirepass 1qaz2wsx > redis.log &
|
redis-server --requirepass yourpass > redis.log &
|
||||||
```
|
```
|
||||||
|
|
||||||
可以通过ps或者netstat来检查Redis服务器是否启动成功。
|
可以通过ps或者netstat来检查Redis服务器是否启动成功。
|
||||||
|
@ -133,7 +133,7 @@ netstat -nap | grep redis-server
|
||||||
|
|
||||||
```Shell
|
```Shell
|
||||||
redis-cli
|
redis-cli
|
||||||
127.0.0.1:6379> auth 1qaz2wsx
|
127.0.0.1:6379> auth yourpass
|
||||||
OK
|
OK
|
||||||
127.0.0.1:6379> ping
|
127.0.0.1:6379> ping
|
||||||
PONG
|
PONG
|
||||||
|
@ -274,7 +274,7 @@ python3
|
||||||
|
|
||||||
```Python
|
```Python
|
||||||
>>> import redis
|
>>> import redis
|
||||||
>>> client = redis.Redis(host='1.2.3.4', port=6379, password='1qaz2wsx')
|
>>> client = redis.Redis(host='1.2.3.4', port=6379, password='yourpass')
|
||||||
>>> client.set('username', 'admin')
|
>>> client.set('username', 'admin')
|
||||||
True
|
True
|
||||||
>>> client.hset('student', 'name', 'hao')
|
>>> client.hset('student', 'name', 'hao')
|
||||||
|
|
|
@ -171,8 +171,8 @@ def find_contacters(con):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
con = pymysql.connect(host='120.77.222.217', port=3306,
|
con = pymysql.connect(host='1.2.3.4', port=3306,
|
||||||
user='root', passwd='123456',
|
user='yourname', passwd='yourpass',
|
||||||
db='address', charset='utf8',
|
db='address', charset='utf8',
|
||||||
autocommit=True,
|
autocommit=True,
|
||||||
cursorclass=pymysql.cursors.DictCursor)
|
cursorclass=pymysql.cursors.DictCursor)
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'oa',
|
'NAME': 'oa',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '1.2.3.4',
|
||||||
'PORT': 3306,
|
'PORT': 3306,
|
||||||
'USER': 'root',
|
'USER': 'yourname',
|
||||||
'PASSWORD': '123456',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,8 @@ DATABASES = {
|
||||||
'NAME': 'shop',
|
'NAME': 'shop',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': 3306,
|
'PORT': 3306,
|
||||||
'USER': 'root',
|
'USER': 'yourname',
|
||||||
'PASSWORD': '123456',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,8 @@ DATABASES = {
|
||||||
'NAME': 'Shop',
|
'NAME': 'Shop',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': 3306,
|
'PORT': 3306,
|
||||||
'USER': 'root',
|
'USER': 'yourname',
|
||||||
'PASSWORD': '123456',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@ from tornado.options import define, options, parse_command_line
|
||||||
|
|
||||||
define('port', default=8888, type=int)
|
define('port', default=8888, type=int)
|
||||||
|
|
||||||
|
# 请求天行数据提供的API数据接口
|
||||||
REQ_URL = 'http://api.tianapi.com/guonei/'
|
REQ_URL = 'http://api.tianapi.com/guonei/'
|
||||||
API_KEY = '772a81a51ae5c780251b1f98ea431b84'
|
# 在天行数据网站注册后可以获得API_KEY
|
||||||
|
API_KEY = 'your_personal_api_key'
|
||||||
|
|
||||||
|
|
||||||
class MainHandler(tornado.web.RequestHandler):
|
class MainHandler(tornado.web.RequestHandler):
|
||||||
|
|
|
@ -14,8 +14,10 @@ from tornado.options import define, options, parse_command_line
|
||||||
|
|
||||||
define('port', default=8888, type=int)
|
define('port', default=8888, type=int)
|
||||||
|
|
||||||
|
# 请求天行数据提供的API数据接口
|
||||||
REQ_URL = 'http://api.tianapi.com/guonei/'
|
REQ_URL = 'http://api.tianapi.com/guonei/'
|
||||||
API_KEY = '772a81a51ae5c780251b1f98ea431b84'
|
# 在天行数据网站注册后可以获得API_KEY
|
||||||
|
API_KEY = 'your_personal_api_key'
|
||||||
|
|
||||||
|
|
||||||
class MainHandler(tornado.web.RequestHandler):
|
class MainHandler(tornado.web.RequestHandler):
|
||||||
|
|
|
@ -15,13 +15,13 @@ define('port', default=8888, type=int)
|
||||||
|
|
||||||
async def connect_mysql():
|
async def connect_mysql():
|
||||||
return await aiomysql.connect(
|
return await aiomysql.connect(
|
||||||
host='120.77.222.217',
|
host='1.2.3.4',
|
||||||
port=3306,
|
port=3306,
|
||||||
db='hrs',
|
db='hrs',
|
||||||
charset='utf8',
|
charset='utf8',
|
||||||
use_unicode=True,
|
use_unicode=True,
|
||||||
user='root',
|
user='yourname',
|
||||||
password='123456',
|
password='yourpass',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,13 @@ define('port', default=8888, type=int)
|
||||||
|
|
||||||
def get_mysql_connection():
|
def get_mysql_connection():
|
||||||
return connect(
|
return connect(
|
||||||
host='120.77.222.217',
|
host='1.2.3.4',
|
||||||
port=3306,
|
port=3306,
|
||||||
db='hrs',
|
db='hrs',
|
||||||
charset='utf8',
|
charset='utf8',
|
||||||
use_unicode=True,
|
use_unicode=True,
|
||||||
user='root',
|
user='yourname',
|
||||||
password='123456',
|
password='yourpass',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,13 @@ from service.handlers.handlers_for_charts import ChartHandler
|
||||||
|
|
||||||
async def connect_mysql():
|
async def connect_mysql():
|
||||||
return await aiomysql.connect(
|
return await aiomysql.connect(
|
||||||
host='120.77.222.217',
|
host='1.2.3.4',
|
||||||
port=3306,
|
port=3306,
|
||||||
db='hrs',
|
db='hrs',
|
||||||
charset='utf8',
|
charset='utf8',
|
||||||
use_unicode=True,
|
use_unicode=True,
|
||||||
user='root',
|
user='yourname',
|
||||||
password='123456',
|
password='yourpass',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -853,7 +853,7 @@ CACHES = {
|
||||||
'CONNECTION_POOL_KWARGS': {
|
'CONNECTION_POOL_KWARGS': {
|
||||||
'max_connections': 1000,
|
'max_connections': 1000,
|
||||||
},
|
},
|
||||||
'PASSWORD': '1qaz2wsx',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
# 页面缓存
|
# 页面缓存
|
||||||
|
@ -868,7 +868,7 @@ CACHES = {
|
||||||
'CONNECTION_POOL_KWARGS': {
|
'CONNECTION_POOL_KWARGS': {
|
||||||
'max_connections': 500,
|
'max_connections': 500,
|
||||||
},
|
},
|
||||||
'PASSWORD': '1qaz2wsx',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
# 会话缓存
|
# 会话缓存
|
||||||
|
@ -884,7 +884,7 @@ CACHES = {
|
||||||
'CONNECTION_POOL_KWARGS': {
|
'CONNECTION_POOL_KWARGS': {
|
||||||
'max_connections': 2000,
|
'max_connections': 2000,
|
||||||
},
|
},
|
||||||
'PASSWORD': '1qaz2wsx',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
# 接口数据缓存
|
# 接口数据缓存
|
||||||
|
@ -899,7 +899,7 @@ CACHES = {
|
||||||
'CONNECTION_POOL_KWARGS': {
|
'CONNECTION_POOL_KWARGS': {
|
||||||
'max_connections': 500,
|
'max_connections': 500,
|
||||||
},
|
},
|
||||||
'PASSWORD': '1qaz2wsx',
|
'PASSWORD': 'yourpass',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1781,7 +1781,7 @@ CORS_ORIGIN_ALLOW_ALL = True
|
||||||
>>> signer.unsign(value)
|
>>> signer.unsign(value)
|
||||||
'hello, world!'
|
'hello, world!'
|
||||||
>>>
|
>>>
|
||||||
>>> signer = Signer(salt='1qaz2wsx')
|
>>> signer = Signer(salt='yoursalt')
|
||||||
>>> signer.sign('hello, world!')
|
>>> signer.sign('hello, world!')
|
||||||
'hello, world!:9vEvG6EA05hjMDB5MtUr33nRA_M'
|
'hello, world!:9vEvG6EA05hjMDB5MtUr33nRA_M'
|
||||||
>>>
|
>>>
|
||||||
|
|
Loading…
Reference in New Issue