Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Simple learning of the basics of MySQL

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report