您好,登錄后才能下訂單哦!
本文主要給大家介紹MySQL管理操作簡析,希望可以給大家補(bǔ)充和更新些知識,如有其它問題需要了解的可以持續(xù)在億速云行業(yè)資訊里面關(guān)注我的更新文章的。
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
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)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| ..... |
| user |
+---------------------------+
31 rows in set (0.00 sec)
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('N','Y') | NO | | N | |
| ... |
| Trigger_priv | enum('N','Y') | NO | | N | |
+-----------------------+---------------+------+-----+---------+-------+
22 rows in set (0.00 sec)
mysql> create database school;
Query OK, 1 row affected (0.00 sec)
mysql> use school;
Database changed
mysql> 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)
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)
mysql> create database school;
Query OK, 1 row affected (0.01 sec)
mysql> use school;
Database changed
mysql> 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.00 sec)
mysql> insert into info (id,name,address) values (1,'zhangsan','beijing');
Query OK, 1 row affected (0.01 sec)
mysql> select * from info; //查看表所有內(nèi)容
+----+----------+---------+
| id | name | address |
+----+----------+---------+
| 1 | zhangsan | beijing |
+----+----------+---------+
1 row in set (0.00 sec)
mysql> update info set address='shanghai' where id=1; //將info表內(nèi)id為1的address更改為shanghai
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from info; //查看表內(nèi)容
+----+----------+----------+
| id | name | address |
+----+----------+----------+
| 1 | zhangsan | shanghai |
+----+----------+----------+
1 row in set (0.00 sec)
mysql> delete from info where id=1; //根據(jù)條件刪除info表中id為1的數(shù)據(jù),不帶where條件時刪除表內(nèi)所有數(shù)據(jù)
Query OK, 1 row affected (0.00 sec)
mysql> select * from info;
Empty set (0.00 sec)
mysql> select * from info; //查看表所有內(nèi)容
+----+----------+---------+
| id | name | address |
+----+----------+---------+
| 1 | zhangsan | beijing |
+----+----------+---------+
1 row in set (0.00 sec)
mysql> select name from info where id=1; //條件查看表內(nèi)容
+----------+
| name |
+----------+
| zhangsan |
+----------+
1 row in set (0.00 sec)
設(shè)置用戶權(quán)限(用戶不存在時。則新建用戶
查看用戶的權(quán)限
看了以上關(guān)于MySQL管理操作簡析,希望能給大家在實(shí)際運(yùn)用中帶來一定的幫助。本文由于篇幅有限,難免會有不足和需要補(bǔ)充的地方,如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時售前售后,隨時幫您解答問題的。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。