My Ubuntu is installed by default python2.7 and 3.4, where Django is installed by Pip (tool for installing and managing Python packages)
Do not install PIP first install PIP tool
Apt-get Install Python-pip
Apt-get Install Python3-pip
The first is the Python 2.x version of the installation tool if you want Django on Python3, use the following.
Pip installs Django online after installation
Pip Install django==1.8
After the equals sign is followed by the Django version number here my is 1.8, Pip applies to Python2, if you want to install under Python3, use the following method
PIP3 Install django==1.8
Python3 installation just change Pip to PIP3
Test Django, and the output version number indicates that the installation was successful.
Then install the Mysqlclient,python connection database.
Install mysqlclient
After installation, the Python directory is dist-packages to be seen.
Open the Python console and enter import MySQLdb, which means the installation was successful without error.
Next, test the connection database:
>>> Import Mysqldb>>> conn = mysqldb.connect (host= ' localhost ', user= ', passwd= ')
Press ENTER to find an error ...
Unable to connect to the database, because I am using the Xmapp environment, MySQL is not in the default path, the connection needs to specify the location of the Mysql.sock connect function parameters unix_socket= ' your Mysql.sock path '
Similarly, under the Django Project, setting.py configures the path of the Mysql.sock
Of course, if you are apt-get install the path by default when the line.
"Summed up a few questions about database Connectivity"
1. First check whether the database service is running
2. There may be a login IP limit, edit MySQL my.cnf
[Mysqld]
Bind-address =127.0.0.1 changed into 0.0.0.0
"Python" Ubuntu installs Django, mysqldb connection database "Xmapp"