After configuring the MySQL database according to the previous tutorial, create a Django project based on the MySQL database! (Summary of the tossing process is not well written. You are welcome to make a picture !) Create a MySQL database first! The procedure is as follows:
1. Check whether MySQL is running
Enter termial and PS-E | grep mysqld.
If similar results are displayed, the operation is correct:
2. Create a User Root and enter the password.
/Usr/local/mysql-5.6.11-osx10.7-x86_64/bin/MySQL-u root-P // a large string of path in front of MySQL path, you find the root for the database line based on their own installation path to create the user
Then you will be asked to enter the password: (the password can be blank)
3. Create a database for the user (datadb)
Mysql> Create Database datadb; (do not forget the semicolon)
If you install MySQL workbench, you can set the connection here:
Click "OK". Then you can see the database you just created in it:
4. connect to and manage the database here:
5. If it succeeds, you can click "continue" until the MySQL database is created:
6. I use eclipse to develop Django, create a new Django project, and use the MySQL database:
Modify settings. py:
Note: 'name': name of the database you created
'User': the user created when you created the database.
'Host': The local address localhost
'Port': Specifies the port address.
So far, select project:
In this case, the console outputs the following information. create the first user when py syncdb is created. If you need to use the admin module of Django, the user created at this time is the user name and password you have obtained during background management Logon:
The MySQL database is successfully created!
7. Run the project. Open http: // 127.0.0.1: 8000/admin/(the admin module is omitted here. Check the information for yourself !)
Pay for commonly used MySQL operation instructions:
// Delete a user
Mysql> Delete from user where user = "phplamp" and host = "localhost ";
// Delete the user's database
Mysql> drop database phplampdb;
// Create a user
Mysql> insert into mysql. User (host, user, password) values ('localhost', 'user', password ('123 '));
// Refresh the system permission list
Mysql> flush privileges;
// Log on after exiting
Mysql> exit;