by
1,258 13
0
2
148
0
Popular
Specified
Created
Modified Sep 2, 2017

Published on:

No tags for this snippet yet.
Languagecsharp
LanguageText
SourceGitHub
SourceMyGists

Install Mysql with Python and Django Debian/Derivatives - Translated

Install Mysql with Python and Django Debian/Derivatives - Translated: 
mysql_python_on_debian.txt
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2582059/Install-Mysql-with-Python-and-Django-Deb?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
#Install Mysql with Python and Django Debian/Derivatives #To install we need to have some dependencies in the system for now we will show on #Debian and Derivatives. #But first install updates and MySQL ``` $ sudo apt-get update $ sudo apt-get upgrade ``` # ** NOTE: ** #Each System has its commands for updating, if your machine is not derived from Debian ** look for them ** ##Install MySQL ``` $ sudo apt-get install mysql-server mysql-client Passwd for 'root' user: <password> ``` #At the end we execute this command to give more security to our BD ``` $ mysql_secure_installation ``` #Check carefully the changes that will be made, the first question is the passwd for root, #IF you want to keep or change it, and continue with other security questions. ##Create a database and a user for the DB #Now we will create the DB that will be connected to DJango and a User with Passwd to access it. #There are two ways to do this: ``` echo "CREATE DATABASE <DATABASENAME>;" | mysql -u root -p echo "CREATE USER '<DATABASEUSER>'@'localhost' IDENTIFIED BY '<PASSWORD>';" | mysql -u root -p echo "GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<DATABASEUSER>'@'localhost';" | mysql -u root -p echo "FLUSH PRIVILEGES;" | mysql -u root -p ``` #So they should put their passwd of mysql in each line or #they can also do it of the following way ``` $ mysql -u root -p ``` #Enter your passwd and then do the following. ``` CREATE DATABASE <DATABASENAME>; CREATE USER '<DATABASEUSER>'@localhost IDENTIFIED BY '<PASSWORD>'; GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<DATABASEUSER>'@localhost; FLUSH PRIVILEGES; exit ``` #We Check Dependencies #There are only a few dependencies but you have to be sure ``` $ sudo apt-get install libmysqlclient-dev python-dev ``` #So far it's all just proceed to install pip in our virtual environment or globally ``` $ sudo -H pip install mysql-python ``` #As you can see now you can create DB and Users for each Django Project
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus