mysql安裝使用,mysql使用

來源:互聯網
上載者:User

mysql安裝使用,mysql使用

在OJ中,mysql主要用來儲存使用者資訊。它的安裝和使用比較簡單,下面簡單介紹一下。首先說明一下我的Linux分支環境是Ubuntu 12.04,其他的分支大致步驟也是類似,可能命令有所不同。

 一、安裝

sudo apt-get install mysql-server

鍵入命令之後需要下載相關的包,慢慢等待即可,等待下載完成,就已經安裝好了。

二、使用

mysql的常見命令還是一樣的,如果之前就熟悉mysql話就很簡單。

本機登入:mysql -u root -p

  1. 建庫:create database oj;
  2. 改變資料庫:use oj;
  3. 顯示資料庫:show databases ;
  4. 顯示表: show tables;
其他的sql操作和其他資料庫大同小異。

三、mysql在OJ中的配置

因為使用到django架構,而我們不使用django自己的資料庫,所以需要在django架構中做合適的配置才能使用mysql。

相關的配置如下:

setting.py

DATABASES = {    'default': {        'ENGINE': 'django.db.backends.mysql',        'NAME': 'oj',           'USER': 'root',           'PASSWORD': 'cugbacm',           'PORT': '3306',           'HOST': '127.0.0.1',    }}

user即是資料庫使用者名稱

password是資料庫密碼

port連接埠為3306

詳細的配置可以參考:https://docs.djangoproject.com/en/1.6/ref/settings/#databases


相關文章

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.