Install and use mysql
In OJ, mysql is mainly used to store user information. It is easy to install and use. The following is a brief introduction. First, I will explain that my Linux branch environment is Ubuntu 12.04, and the general steps of other branches are similar, and the commands may be different.
I. Installation
Sudo apt-get install mysql-server
After you enter the command, you need to download the relevant package. Wait for the package to be downloaded. The package has been installed.
Ii. Use
The common mysql commands are the same. If you are familiar with mysql before, it is very easy.
Local Logon: mysql-u root-p
Database creation: create database oj;
Change Database: use oj;
Display Database: show databases;
Display table: show tables. Other SQL operations are similar to those of other databases.
Iii. configuration of mysql in OJ
Because the django framework is used, and we do not use django's own database, we need to make appropriate configurations in the django framework to use mysql.
The related configurations are as follows:
Setting. py
DATABASES = {'default': {'Engine ': 'django. db. backends. mysql ', 'name': 'oj', 'user': 'root', 'Password': 'cugbacm', 'Port': '123', 'host ': '2017. 0.0.1 ',}}
The user is the database user name.
Password is the Database password
Port 3306