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

Summary of Common commands in Mysql Database

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

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "summary of common commands in Mysql database". In the operation of actual cases, many people will encounter such a dilemma, 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!

Start the Mysql database

C: "cdMysql5.0bin

C:Mysql5.0bin "mysqld-install installs Mysql service

C:Mysql5.0bin "netstartmysql starts the Mysql service

The requested service has been started.

Connect mysql

Users need to provide the user name and password of Mysql to connect to the server, and if the server is not local, a hostname or IP is required to specify the location of the server.

C:Mysql5.0bin "mysql-hlocalhost-uroot-p

EnterpassWord:****

WelcometotheMySQLmonitor.Commandsendwith;org.

YourMySQLconnectionidis6toserverversion:5.0.18-nt

Type'help;'or'h'forhelp.Type'c'toclearthebuffer.

Mysql "

Use a simple query statement

Mysql "selectversion (), current_date

Mysql "selectversion (); selectnow ()

Create or delete a database

Mysql "createdatabasemydb

Mysql "dropdatabasemydb

Commands for open databases

Mysql "usemysql

Databasechanged

Command to view the database

Mysql "showdatabases

View the detailed structure of the data table

Mysql "descfunc

Create a new database

Mysql "createdatabaseschool

QueryOK,1rowaffected (0.00sec)

New table

Mysql "createtableuser01 (

-"idvarchar (20) NOTNULL

-"userNamevarchar (10) NOTNULL

-"ageint (11) default'0'

-"sexchar (2) NOTNULLdefault'm'

-"PRIMARYKEY (id)

-") TYPE=InnoDB

QueryOK,0rowsaffected,1warning (0.02sec) mysql "descstudent

What are the common commands in Mysql database

Insert and delete data from a table

Createtablestudent (stuNamevarchar (20), agevarchar (20), idvarchar (20), set0char (1))

insert

Mysql "insertintostudent (id,stuName) values ('1century recorder tomcat')

QueryOK,1rowaffected (0.00sec)

Delete

Mysql "deletefromstudentwhereid='1'

QueryOK,1rowaffected (0.01sec)

Delete all data in the table

Mysql "truncatetablestudent

QueryOK,1rowaffected (0.01sec)

Delete tabl

Mysql "createtabletemp (tvarchar (1))

QueryOK,0rowsaffected (0.00sec)

Mysql "droptabletemp

QueryOK,0rowsaffected (0.00sec)

Create a new user and grant permissions

Mysql "grantallprivilegeson*.*todbuser@localhostidentifiedby'1234'

Withgrantoption

Change Mysql user password

C:Mysql5.0bin "mysqladmin-uroot-ppassword1234

Enterpassword:****

Back up databases and tables

We use the mysqldump command to back up the database

C:mysqlbin "mysqldump-uroot-p3306mysql" d:backup.sql

Executing this statement will back up the mydb to the backup.sql file on disk D.

Back up multiple database tables

C:mysqlbin "mysqldump-uroot-p3306schooluser01user" d:backup.sql

This sentence means to back up the contents and definitions of the user01 table and user table in the school library to the D disk backup.sql file.

Back up all databases

C:myqlbin "mysqldump-uroot-p3306-all-database" d:backup.sql

Restore Mysql database

C:mysqlbinmysql-uroot-p3306school

Restore one of the tables

Mysql "sourced:books.sql

ERROR:

Unknowncommand'b' .

QueryOK,0rowsaffected (0.00sec)

QueryOK,1rowaffected (0.00sec)

Exit Mysql connection

Mysql "quit (exit)

Turn off the mysql service

C:mysqlbin "netmysql

This is the end of the summary of common commands in Mysql database. Thank you for your 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

Database

Wechat

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

12
Report