Environment
Win10,python3.6,pycharm,mysql57
Installation
MySQL installation, the cost of a bit of trouble, then install Pymysql:
Pip Install Pymysql
Then you can use python3.6 to operate MySQL, but to use MySQL in the pycharm, you need some steps, see http://www.jb51.net/article/112715.htm and http:// blog.csdn.net/tongxinzhazha/article/details/70257014, in short, is:
1. Find and install Databbase Navigator in the Pycharm setting-plugins
2. Download MySQL Jdbcmysql-connector-java and put it in any directory
3. Open the database plugin of pycharm, add a MySQL connection, fill in the host, database name (in advance database), username, login password, Then change the driver path to the path of file Mysql-connector-java-5.1.45-bin.jar in 2.
Using the command line to manipulate MySQL
cmd command Line window into D:\mysql57\soft\bin, first typed net start MySQL, make sure MySQL is started, and then typed Mysql-u root-p, Prompt for a password (forget to check with your girlfriend's chat history) and then go to MySQL interface.
Refer to big bro and this
Python operation MySQL
First of all
import MySQL
Then connect to the database
Connect = pymysql. Connect ( host='localhost', Port=3306, user=' root', passwd=' password ', db=' database name ', charset='UTF8' )
Reference http://blog.csdn.net/johline/article/details/69549131 and Insect master
Python operation MySQL database