上一篇文章介绍了如何安装与配置Django和Apache. 这篇文章将介绍如何连接Django和MySQL.
Install MySql
1 |
|
Here I met a error said
1 |
|
After some search and debug, this solved my problem. Basically, run:
1 |
|
And I found
1 |
|
Then I went to /etc/mysql/mysql.conf.d/mysqld.cnf
, added innodb_buffer_pool_size = 20M
under line [mysqld]
. Then reinstall the mysql-server again. Then improve mySQL installation security by running
1 |
|
some useful cmd for sql:
1 |
|
Create database and MySQL account for Django Application
Run following cmd to create database and user.
1 |
|
Install mysqlclient
Run following cmd to install mysqlclient.
1 |
|
Connecting to the database
Modify the settings.py of the Django project with following
1 |
|
Then run the cmd to create tables.
1 |
|