In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces you a brief analysis of MySQL management operation, hoping to supplement and update some knowledge, if you have other questions to understand, you can continue to follow my updated article in the industry information.
Mysql management operations database management operations view database structure create and delete records of libraries and table management tables basic operations commands view database list information SHOW DATABASES
[root@localhost] # mysql-u root-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 3Server version: 5.7.17 Source distributionCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ 4 rows in set (0.00 sec) View the data table information in the database USE data Library name SHOW TABLESmysql > use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changedmysql > show tables +-- + | Tables_in_mysql | +-+ | columns_priv | | db | | engine_cost | | event | |. | | user | +-+ 31 rows in set (0.00 sec) displays the structure (field) of the data table DESCRIBE [database name] Table name mysql > describe db +-- +-+ | Field | Type | Null | Key | Default | Extra | +-- + -+ | Host | char (60) | NO | PRI | | Db | char (64) | NO | PRI | | User | | cha (32) | NO | PRI | | Select_priv | enum ('N') | |'Y') | NO | | N | Execute_priv | enum ('Nickel dagger') | NO | | N | |. | | Trigger_priv | enum ('N') | 'Y') | NO | | N | | +-+-+ 22 rows in set (0.00 sec) SQL statement Overview SQL language is the abbreviation of Structured Query Language That is, structured query language is the standard language for maintaining and managing relational databases, such as data query, data update, access control, object management and other functions SQL classification DDL: data definition language DML: data manipulation language DQL: data query language DCL: data control language DDL statement operation DDL statement is used to create database objects Such as libraries, tables, indexes, etc. Use DDL statements to create new libraries, tables to create databases: CREATE DATABASE database name to create data tables: CREATE TABLE table name (field definition) mysql > create database school Query OK, 1 row affected (0.00 sec) mysql > use school;Database changedmysql > create table info (- > id int (4),-> name char (10) not null,-> address varchar (50) default 'nanjing',-> primary key (id); Query OK, 0 rows affected (0.01 sec) mysql > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | school | | sys | +-+ 5 rows in set (0.00 sec) mysql > show tables +-+ | Tables_in_school | +-+ | info | +-+ 1 row in set (0.00 sec) DDL statement operation use DDL statement to delete database and table delete specified data table: DROP TABLE [database name.] Table name deletes the specified database: DROP DATABASE database name mysql > drop table info;Query OK, 0 rows affected (0.00 sec) mysql > show tables;Empty set (0.00 sec) mysql > drop database school;Query OK, 0 rows affected (0.00 sec) mysql > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ 4 rows in set (0.00 sec) DML statement operates the DML statement to match the number in the table According to the management, INSERT includes the following operations: insert new data UPDATE: update existing data DELETE: delete unwanted data mysql > create database school Query OK, 1 row affected (0.01 sec) mysql > use school;Database changedmysql > create table info (- > id int (4) not null,-> name char (10) not null,-> address varchar (50) default 'nanjing',-> primary key (id); Query OK, 0 rows affected (0 sec) mysql > insert into info (id,name,address) values; Query OK, 1 row affected (0 sec) mysql > select * from info / / View all the contents of the table +-+ | id | name | address | +-+ | 1 | zhangsan | beijing | +-+ 1 row in set (0.00 sec) mysql > update info set address='shanghai' where id=1 / / change the address with id 1 in the info table to shanghaiQuery OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0mysql > select * from info / / View table contents +-+ | id | name | address | +-+ | 1 | zhangsan | shanghai | +-+ 1 row in set (0.00 sec) mysql > delete from info where id=1 / delete the data with id 1 in the info table according to the condition, delete all data Query OK in the table without where condition, 1 row affected (0.00 sec) mysql > select * from info;Empty set (0.00 sec) DQL statement operation DQL is a data query statement, only one: SELECT can be used to find qualified data records from the data table without specifying the conditional SELECT field name 1, field name 2. FROM table name mysql > select * from info; / / View all the contents of the table +-+ | id | name | address | +-+ | 1 | zhangsan | beijing | +-+ 1 row in set (0.00 sec) mysql > select name from info where id=1 / / conditional view table content +-+ | name | +-+ | zhangsan | +-+ 1 row in set (0.00 sec) DCL statement operation
Set user permissions (when the user does not exist. Then create a new user
GRANT permission list ON database name. Table name TO username @ source address [IDENTIFIED BY 'password']
View the user's permissions
SHOW GRANT FOR user name @ source address revokes the user's permissions REVOKE permission list ON database name. Table name FROM user name @ Source address
After reading the above brief analysis of MySQL management operation, I hope it can bring some help to everyone in practice. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.