Mysql Installation and Use

Source: Internet
Author: User
Tags mysql commands

Mysql Installation and Use

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

  1. Database creation: create database oj;
  2. Change Database: use oj;
  3. Display Database: show databases;
  4. 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': '3306',           'HOST': '127.0.0.1',    }}

The user is the database user name.

Password is the Database password

Port 3306

Detailed configuration can refer to: https://docs.djangoproject.com/en/1.6/ref/settings/#databases


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.