Get the App
SLTechnology News&Howtos  ›  Database  › 

Simple learning of the basics of MySQL

Shulou Source: shulou.com Published: 2022-06-01 19:45:57 10月22日 Update

The following is followed by the author to understand the simple learning of the MySQL foundation. I believe everyone will benefit a lot after reading it. The text is not much in the essence. I hope the simple learning of the MySQL foundation is what you want.

Login:

Mysql-u root-p

-p can be followed by a password

Enter the database:

Use mydb

Mydb is the database you want to access.

Create the database:

Create database databasename

Create a table:

CREATE TABLE studets (name char (5), sex char (1), grade int) ENGINE INNODB DEFAULT CHARSET=utf8

Insert data:

Insert into studets (name,sex,grade) values (Xiaomi, female, 97)

Python connects to the MySQL database and inserts data:

Import pymysqlconn = pymysql.connect (host= 'localhost',user=' root',passwd='momiao5201314',db='mydb',port=3306,charset='utf8') # Connect to the database cursor = conn.cursor () # create the cursor object cursor.execute ("insert into students (name,sex,grade) values (% s name,sex,grade% s)", ('Wang Wu', 'male', '88') # execute the SQL statement, insert a data conn.commit () # release the connection

After reading this article on the basis of MySQL, many readers will want to know more about it. For more industry information, you can follow our industry information section.

Tags: Data database foundation learning content more industry affirmation benefit a lot information cursor password object millet text friend column author article sentence Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Huawei NVidia Shulou Information