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

How to connect to Mysql database

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "how to connect the Mysql database". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Command line to connect to the database

Mysql-uroot-proot / / specify user name and password

II. Database statement

1. Database operation

Show databases;// display database

Create database jay;// create a new database

Drop database jay;// delete database rename database jay to jay1;// modify database

2. Table operation

Use jay;// selects the database to create a new table with the name zhuanjicreate table zhuanji (id int primary key auto_increment,//id field, int type, keyword, automatically add name varchar not null,//name field, string, empty year int not null,//year field, int type, empty zhudage varchar (255not null) is not allowed) / / zhudage field, string, do not allow new table name for empty usercreate table zhuanji (id int primary key auto_increment,//id field, int type, keyword, automatically add name varchar (255i) not null,//name field, string, do not allow empty pass varchar (255not null) / / year field, int type, do not allow viewing existing table for empty show tables;// drop table zhuanji;// delete table

3. Insert data

Insert into zhuanji (name,year,zhudage) values ("Qi Li Xiang", "2004", "Qi Li Xiang / Grandma / my place"); insert into zhuanji (name,year,zhudage) values ("Chopin in November", "2005", "Nocturne / Snow / Coral Sea"); insert into zhuanji (name,year,zhudage) values ("I'm busy", "2007", "Blue and White porcelain / I don't deserve / Rainbow")

Insert into user (name,pass) values ("aiyou", md5 (123456)); insert into user (name,pass) values ("admin", md5 ("admin"))

4. Query data

Select * from zhuanji;// queries all the data of the zhuanji table

Select * from zhuanji where id=1;// queries data with id 1

5. Modify data

Update zhuanji set zhudage= "Qilixiang / my territory / General" where id=1

6. Delete data

Delete from zhuanji where id=1;// delete id 1 data "how to connect to the Mysql database" content here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report