Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to connect to Mysql database

Shulou Source: shulou.com Published: 2022-06-01 18:06:47 09月15日 Update

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!

Tags: Data database field type Qiliang character string Qili query keyword content name my site more knowledge table unworthy practical successful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Shulou Tech Info Huawei MariaDB