1, download, download version too much, do not know which is good, others introduced version
Go to the official website-click on the bottom downloads--> select MySQL on Windows (Installer & Tools)-->mysql installer--> Select
Windows (x86, 32-bit), MSI Installer 5.7.20 376.3M (mysql-installer-community-5.7.20.0.msi) My computer is WIN10 64 bit, also do not know why choose 32- Bit
2, installation, normal step by step click Install
3. Basic operation of MySQL database
ImportPymysqlImportPandas as PD#do the most basic first, and then slowly adjust the optimization in practice#First, connect the databaseCon=pymysql.connect (host='localhost', user='Root', password='1***', database=' World') Cursor=con.cursor ()#ii. Creating databases and Tables#Create a database#create_schema= "CREATE schema abc"#Cursor.execute (Create_schema)##创建表#create_table= ' CREATE TABLE ABC. Persons\# (\#id_p int not null,\#LastName varchar (255) Not null,\#FirstName varchar (255), \#Address varchar (255), \#City varchar (255) \#) '#Cursor.execute (create_table)#third, delete the table, delete the database#drop_table= "drop table Abc.persons"#Cursor.execute (drop_table)#drop_schema= ' drop schema abc '#Cursor.execute (Drop_schema)#Iv. Writing DataInsert_data="INSERT INTO ABC. Persons values (1, ' A ', ' B ', ' C ', ' d ')"Cursor.execute (insert_data)#Delete some data, if a row of data input error, can be deleted and then write#if the entire data is to be modified, you can delete the table, create a new table#1. Delete one row (multiple rows or columns can be looped)#drop_row= ' Delete from abc.persons where Id_p=1 '#Cursor.execute (Drop_row)#2. Delete a columndrop_column='ALTER TABLE abc.persons drop column City' #ALTER TABLE ***.*** DROP column * *Cursor.execute (drop_column)#3. Add a column or columns of data#add_column= ' ALTER TABLE abc.persons add city varchar (255) '#Cursor.execute (add_column)Con.commit ()#Six, read the data#QueryStringquerystring='SELECT * from Sakila.actor'#reading data using Read_sqlData=pd.read_sql (querystring, con);Print(Data.head ())
MySQL using notes