Use MySQL in Django1.6 + Python3 under Fedora20

Source: Internet
Author: User
Tags python mysql
I spent the whole afternoon studying how to use MySQL in Django1.6 + Python3 under Fedora20 and record it. Recommended: ttuserver12.04 install Nginx + uWSGI + Django environment ghost/

I spent the whole afternoon studying how to use MySQL in Django1.6 + Python3 under Fedora 20 and record it.

Recommended reading:

Install Nginx + uWSGI + Django environment http://www.linuxidc.com/Linux/2012-05/60639.htm on Ubuntu Server 12.04

Django practical tutorial http://www.linuxidc.com/Linux/2013-09/90277.htm

Django Python MySQL Linux development environment build http://www.linuxidc.com/Linux/2013-09/90638.htm

-------------------------------- Split line --------------------------------

1. Install

First of all, as a little white guy, I have taken a lot of detours (both sqlite3 and I don't need to configure any results. I thought this is the same for other databases !) ('_ Region ')

First, install mysql and related things. At that time, I installed all the related things because of a problem ..

$ Sudo yum install mysql-server mysql-connector-python3 mysql-devel

It will replace the mysql originally in fedora. In addition, I didn't install mysql-server at the time, so I was always in the GG status ....

Next, you need to turn the mysql-for-python3 click to open the link if the pip-python3 is installed, you can use

$ Sudo pip-python3 install GitHub + https://github.com/clelland/MySQL-for-Python-3 2.

Configure mysql first. It should be installed with yum, so it has been initialized. The initial user is root, and the password is empty. First,

$ Sudo service mysqld start

Enable the service. You can view the status of service mysqld status. stop indicates that the service is stopped. Keep enabled. Next, go to the command line management mode.

$ Mysql-u user-p

Enter a password. The password is blank by default. At this time, you may also be able to access the website as a user.

$ Mysql

Then

Mysql>

The non-Administrator mode is currently in, with low permissions. Yes

Mysql> show databases;

What I see is

+ -------------------- + | Database | + -------------------- + | information_schema | + -------------------- + 1 row in set (0.01 sec)

To create a new database, you can

Mysql> create database newdatabase character set utf8;

Note that the name must be in lower case and you need to log on as an administrator to create it. For example, if the password of sudo mysql or mysql-u root-p is empty,

In addition, please specify the utf8 encoding when creating the database, otherwise there will be errors when saving Chinese!

Suppose I have created a new newdatabase in settings. py of the django project, and set to use mysql.

DATABASES = {
'Default ':{
'Engine': 'django. db. backends. mysql ',
'Name': 'newdatabase ',
'User': 'root ',
'Password ':'',
'Host': 'localhost ',
'Port': '123 ',
}
}

Now we can connect to the new database.

$ Python3 manage. py syncdb

OK! A database is created!

Django details: Click here
Django's: Click here

For more information about Fedora, see Fedora topics page http://www.linuxidc.com/topicnews.aspx? Tid = 5

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-05/101188.htm

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.