# 首发链接:[https://chen-yijie.blogspot.com/2018/10/uwsgi-django.html](https://chen-yijie.blogspot.com/2018/10/uwsgi-django.html)
## mysqlclient 安装出错
缺失依赖
```
apt-get install libmysqlclient-dev
```
## mysql 本地无法连接
用``mysql -uroot -p``出现
```
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
```
或者Django 连接时出现类似报错
```
django.db.utils.OperationalError: (1698, "Access denied for user 'root'@'localhost'")
```
#### 解决方法
[https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost](https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost)
## mysql设置字符集
```
CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
```
## uwsgi报错
1. ``Importerror no module named 'encodings'``
无法找到标准库: python解释器路径设置 ``python-home``有误
> 以在项目根目录 建立 virtualenv环境 ``env`` 为例:
``python-home`` 设置为 ``env/`` **而不是 ``env/bin``**
2. ``ImportError: No module named 'django'``
缺失外部库路径
添加``pythonpath = env/lib/python3.5/site-packages/``(3.5版本)
**注意python版本!!**
完整uwsgi配置文件(ini):
```
[uwsgi]
chdir = [/path/to/your/project]/[PROJECT_NAME]/
python-home = [/path/to/your/project]/[PROJECT_NAME]/env
pythonpath = env/lib/python3.5/site-packages/
module = [PROJECT_NAME].wsgi
socket = [127.0.0.1:8000]
master = true
vhost = true
no-site = true
workers = 2
reload-mercy = 10
vacuum = true
max-requests = 1000
limit-as = 512
buffer-size = 300000
pidfile= [uwsgi.pid]
daemonize = [logfile.log]
```
[]内请自行替换
####
网友评论